detail.vue 6.4 KB

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