detail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="virtualGoods-detail">
  3. <view class="content">
  4. <!-- <view class="popup-title">会员充值</view> -->
  5. <view class="goods-box">
  6. <image class="icon" :src="chooseInfo.cover.length&&chooseInfo.cover[0]" mode=""></image>
  7. <view class="goods-info">
  8. <view class="goods-title">
  9. {{chooseInfo.title}}
  10. </view>
  11. <view class="goods-desc">
  12. {{chooseInfo.title}}
  13. </view>
  14. </view>
  15. <view class="price">
  16. ¥{{chooseInfo.salePrice}}
  17. </view>
  18. </view>
  19. <view class="notice">
  20. 暂不提供IOS用户进行充值业务
  21. </view>
  22. <u--form labelPosition="top" :model="form" ref="uForm" borderBottom labelWidth="180rpx" :labelStyle="{'color': '#222222',
  23. 'font-weight': 'bold','line-height':'60rpx','font-size': '28rpx'}">
  24. <u-form-item label="账号类型" borderBottom ref="item1">
  25. <view class="type-box" @click="open">
  26. <view class="">
  27. {{type}}
  28. </view>
  29. <image class="icon" src="../../static/right.png" mode=""></image>
  30. </view>
  31. </u-form-item>
  32. <u-form-item label="充值账号" prop="account" borderBottom ref="item1">
  33. <u--input v-model.trim="form.account" placeholder="请输入充值账号" border="none"></u--input>
  34. </u-form-item>
  35. </u--form>
  36. <view class="goods-describe">
  37. <rich-text :nodes="chooseInfo.goodsDescribe"></rich-text>
  38. </view>
  39. <view class="sub-title">
  40. 商品说明
  41. </view>
  42. <view class="notice-text">
  43. <view class="">
  44. 充值方式:自动充值,填写登录时绑定的手机号/邮箱号等对应账号;
  45. </view>
  46. <view class="">
  47. 有效期说明:有效期自购买之日算起,过期即失效。
  48. </view>
  49. </view>
  50. <view class="sub-title">
  51. 温馨提示
  52. </view>
  53. <view class="notice-text">
  54. <view class="">
  55. 1、仅支持在中国境内使用。
  56. </view>
  57. <view class="">
  58. 2、本产品为虚拟商品,一经付款,无法办理退款退货;
  59. </view>
  60. <view class="">
  61. 3、充值前请核对充值账号,切勿填错,如因用户个人原因充错,责任自行承担;
  62. </view>
  63. <view class="">
  64. 4、充值成功后,请登录官方网站/APP查询您的会员状态和有效期;
  65. </view>
  66. <view class="">
  67. 5、如有其他限制,以所充值会员的官方规定为准。
  68. </view>
  69. </view>
  70. <button class="btn" type="default" :loading="loading" @click="handleBuy">确认</button>
  71. </view>
  72. <!-- 商品说明
  73. 充值方式:自动充值,填写登录时绑定的手机号/邮箱号等对应账号;
  74. 有效期说明:有效期自购买之日算起,过期即失效。
  75. 温馨提示
  76. 1、仅支持在中国境内使用。
  77. 2、本产品为虚拟商品,一经付款,无法办理退款退货;
  78. 3、充值前请核对充值账号,切勿填错,如因用户个人原因充错,责任自行承担;
  79. 4、充值成功后,请登录官方网站/APP查询您的会员状态和有效期;
  80. 5、如有其他限制,以所充值会员的官方规定为准。 -->
  81. <u-modal :show="iosShow" content='暂不提供IOS用户进行充值业务' @confirm="confirm"></u-modal>
  82. <!-- 选择账号类型 -->
  83. <u-picker :show="show" :value='shopIndex' keyName="label" :closeOnClickOverlay="false" :columns="list" @confirm="choose" @cancel="cancel"></u-picker>
  84. </view>
  85. </template>
  86. <script>
  87. import {SHOP_ID} from '@/utils/config.js'
  88. export default {
  89. data() {
  90. return {
  91. show:false,
  92. iosShow: false,
  93. chooseInfo: {channel_price:0},
  94. type:'手机号',
  95. form:{
  96. account:'',
  97. accountType:1,
  98. productId:''
  99. },
  100. list:[
  101. [
  102. {
  103. label:'手机号',
  104. value:1,
  105. },
  106. {
  107. label:'QQ号',
  108. value:2,
  109. },
  110. {
  111. label:'邮箱',
  112. value:0,
  113. },
  114. ]
  115. ]
  116. }
  117. },
  118. methods: {
  119. confirm(){
  120. this.iosShow = false
  121. },
  122. cancel(){
  123. this.show = false
  124. },
  125. open(){
  126. this.show = true
  127. },
  128. choose(val){
  129. console.log(val.value[0]);
  130. this.type = val.value[0].label
  131. this.form.accountType = val.value[0].value
  132. this.$nextTick(()=>{
  133. this.show = false
  134. })
  135. },
  136. // 创建订单
  137. handleBuy() {
  138. if (uni.getStorageSync('token')) {
  139. if(JSON.parse(uni.getStorageSync('userInfo')).setMealCode != 0&&JSON.parse(uni.getStorageSync('userInfo')).setMealCode){
  140. if(!this.form.account) return uni.showToast({
  141. title:'请输入充值账号',
  142. icon:'none'
  143. })
  144. let that = this
  145. uni.getSystemInfo({
  146. success(res){
  147. console.log(res.osName);
  148. if(res.osName == 'ios'){
  149. that.show = false
  150. that.iosShow = true
  151. }else{
  152. if(that.form.accountType == 1 &&!uni.$u.test.mobile(that.form.account)){
  153. return uni.showToast({
  154. title:'账号格式错误',
  155. icon:'none'
  156. })
  157. }else if(that.form.accountType == 2 && !uni.$u.test.digits(that.form.account)){
  158. return uni.showToast({
  159. title:'账号格式错误',
  160. icon:'none'
  161. })
  162. }else if(that.form.accountType == 0 &&!uni.$u.test.email(that.form.account)){
  163. return uni.showToast({
  164. title:'账号格式错误',
  165. icon:'none'
  166. })
  167. }
  168. let info = {
  169. price:that.chooseInfo.salePrice,
  170. goodsName:that.chooseInfo.title,
  171. accountType:that.form.accountType,
  172. rechargeAccount:that.form.account,
  173. productId:that.chooseInfo.pid,
  174. goodsImg:that.chooseInfo.cover&&that.chooseInfo.cover.length?that.chooseInfo.cover[0]:'',
  175. }
  176. uni.navigateTo({
  177. url:`/detail/virtualGoods/pay`,
  178. success: function(res) {
  179. // 通过eventChannel向被打开页面传送数据
  180. res.eventChannel.emit('pay', info)
  181. }
  182. })
  183. }
  184. }
  185. })
  186. }else{
  187. uni.showModal({
  188. title:'此商品需要开通会员才能购买',
  189. cancelText:'下次再说',
  190. confirmText:'立即开通',
  191. success(res) {
  192. if(res.confirm){
  193. uni.navigateTo({
  194. url:'/my/memberCenter/index'
  195. })
  196. }
  197. }
  198. })
  199. }
  200. } else {
  201. uni.showModal({
  202. title:'请登录',
  203. confirmText:'去登录',
  204. success(res){
  205. console.log(res);
  206. if(res.confirm){
  207. uni.navigateTo({
  208. url:'/login/login/login?redirect=/detail/virtualGoods/index'
  209. })
  210. }
  211. }
  212. })
  213. }
  214. }
  215. },
  216. onLoad() {
  217. let that = this
  218. const eventChannel = this.getOpenerEventChannel();
  219. eventChannel.on('data', function(data) {
  220. console.log('da',data);
  221. that.chooseInfo = data
  222. that.chooseInfo.salePrice = (that.chooseInfo.salePrice/100).toFixed(2)
  223. })
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. .virtualGoods-detail {
  229. padding-bottom: 200rpx;
  230. .content{
  231. padding: 24rpx;
  232. .popup-title{
  233. font-size: 32rpx;
  234. font-weight: bold;
  235. color: #222222;
  236. }
  237. .type-box{
  238. display: flex;
  239. justify-content: space-between;
  240. align-items: center;
  241. .icon{
  242. width: 40rpx;
  243. height: 40rpx;
  244. }
  245. }
  246. .goods-box{
  247. display: flex;
  248. margin-top: 28rpx;
  249. .icon{
  250. width: 160rpx;
  251. height: 160rpx;
  252. border-radius: 16rpx;
  253. background: #F0F0F0;
  254. }
  255. .goods-info{
  256. display: flex;
  257. flex-direction: column;
  258. justify-content: space-around;
  259. flex: 1;
  260. margin-left: 20rpx;
  261. .goods-title{
  262. color: #222222;
  263. font-weight: bold;
  264. font-size: 36rpx;
  265. }
  266. .goods-desc{
  267. font-size: 28rpx;
  268. color: #AAAAAA;
  269. }
  270. }
  271. .price{
  272. color: $uni-color-primary;
  273. font-size: 36rpx;
  274. font-weight: bold;
  275. align-self: center;
  276. }
  277. }
  278. .notice{
  279. font-size: 24rpx;
  280. color: #AAAAAA;
  281. padding: 26rpx 0;
  282. border-bottom: 2rpx solid #F0F0F0;
  283. }
  284. .goods-describe{
  285. color: #222222;
  286. font-size: 24rpx;
  287. max-height: 480rpx;
  288. padding-top: 28rpx;
  289. overflow: auto;
  290. }
  291. .sub-title{
  292. font-weight: bold;
  293. font-size: 32rpx;
  294. color: #222222;
  295. margin: 20rpx 0;
  296. }
  297. .notice-text{
  298. font-size: 24rpx;
  299. color: #AAAAAA;
  300. line-height: 44rpx;
  301. }
  302. .btn{
  303. position: fixed;
  304. left: 30rpx;
  305. bottom: env(safe-area-inset-bottom);
  306. width: 690rpx;
  307. height: 80rpx;
  308. line-height: 80rpx;
  309. background: $uni-color-primary;
  310. border-radius: 46rpx;
  311. margin-top: 54rpx;
  312. font-size: 28rpx;
  313. color: #fff;
  314. }
  315. }
  316. }
  317. </style>