detail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. <u-modal :show="iosShow" content='暂不提供IOS用户进行充值业务' @confirm="iosShow = false"></u-modal>
  42. <!-- 选择账号类型 -->
  43. <u-picker :show="show" :value='shopIndex' keyName="label" :closeOnClickOverlay="false" :columns="list" @confirm="choose" @cancel="show = false"></u-picker>
  44. </view>
  45. </template>
  46. <script>
  47. import {SHOP_ID} from '@/utils/config.js'
  48. export default {
  49. data() {
  50. return {
  51. show:false,
  52. iosShow: false,
  53. chooseInfo: {channel_price:0},
  54. type:'手机号',
  55. form:{
  56. account:'',
  57. accountType:1,
  58. productId:''
  59. },
  60. list:[
  61. [
  62. {
  63. label:'手机号',
  64. value:1,
  65. },
  66. {
  67. label:'QQ号',
  68. value:2,
  69. },
  70. {
  71. label:'其他',
  72. value:0,
  73. },
  74. ]
  75. ]
  76. }
  77. },
  78. methods: {
  79. choose(val){
  80. console.log(val.value[0]);
  81. this.type = val.value[0].label
  82. this.form.accountType = val.value[0].value
  83. this.$nextTick(()=>{
  84. this.show = false
  85. })
  86. },
  87. // 创建订单
  88. handleBuy() {
  89. if (uni.getStorageSync('token')) {
  90. if(JSON.parse(uni.getStorageSync('userInfo')).setMealCode == 0){
  91. if(!this.form.account) return uni.showToast({
  92. title:'请输入充值账号',
  93. icon:'none'
  94. })
  95. let that = this
  96. uni.getSystemInfo({
  97. success(res){
  98. console.log(res.osName);
  99. if(res.osName == 'ios'){
  100. that.show = false
  101. that.iosShow = true
  102. }else{
  103. let info = {
  104. price:Number(that.chooseInfo.channel_price).toFixed(2),
  105. goodsName:that.chooseInfo.item_name,
  106. accountType:that.form.accountType,
  107. rechargeAccount:that.form.account,
  108. productId:that.chooseInfo.product_id
  109. }
  110. uni.navigateTo({
  111. url:`/detail/virtualGoods/pay`,
  112. success: function(res) {
  113. // 通过eventChannel向被打开页面传送数据
  114. res.eventChannel.emit('pay', info)
  115. }
  116. })
  117. }
  118. }
  119. })
  120. }else{
  121. uni.showModal({
  122. title:'此商品需要开通会员才能购买',
  123. cancelText:'下次再说',
  124. confirmText:'立即开通',
  125. success(res) {
  126. if(res.confirm){
  127. uni.navigateTo({
  128. url:'/my/memberCenter/index'
  129. })
  130. }
  131. }
  132. })
  133. }
  134. } else {
  135. uni.showModal({
  136. title:'请登录',
  137. confirmText:'去登录',
  138. success(res){
  139. console.log(res);
  140. if(res.confirm){
  141. uni.navigateTo({
  142. url:'/login/login/login?redirect=/detail/virtualGoods/index'
  143. })
  144. }
  145. }
  146. })
  147. }
  148. }
  149. },
  150. onLoad() {
  151. let that = this
  152. const eventChannel = this.getOpenerEventChannel();
  153. eventChannel.on('data', function(data) {
  154. console.log('da',data);
  155. that.chooseInfo = data
  156. })
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .virtualGoods-detail {
  162. .content{
  163. padding: 24rpx;
  164. .popup-title{
  165. font-size: 32rpx;
  166. font-weight: bold;
  167. color: #222222;
  168. }
  169. .type-box{
  170. display: flex;
  171. justify-content: space-between;
  172. align-items: center;
  173. .icon{
  174. width: 40rpx;
  175. height: 40rpx;
  176. }
  177. }
  178. .goods-box{
  179. display: flex;
  180. margin-top: 28rpx;
  181. .icon{
  182. width: 160rpx;
  183. height: 160rpx;
  184. border-radius: 16rpx;
  185. background: #F0F0F0;
  186. }
  187. .goods-info{
  188. display: flex;
  189. flex-direction: column;
  190. justify-content: space-around;
  191. flex: 1;
  192. margin-left: 20rpx;
  193. .goods-title{
  194. color: #222222;
  195. font-weight: bold;
  196. font-size: 36rpx;
  197. }
  198. .goods-desc{
  199. font-size: 28rpx;
  200. color: #AAAAAA;
  201. }
  202. }
  203. .price{
  204. color: $uni-color-primary;
  205. font-size: 36rpx;
  206. font-weight: bold;
  207. align-self: center;
  208. }
  209. }
  210. .notice{
  211. font-size: 24rpx;
  212. color: #AAAAAA;
  213. padding: 26rpx 0;
  214. border-bottom: 2rpx solid #F0F0F0;
  215. }
  216. .goods-describe{
  217. color: #222222;
  218. font-size: 24rpx;
  219. max-height: 480rpx;
  220. padding-top: 28rpx;
  221. overflow: auto;
  222. }
  223. .btn{
  224. position: fixed;
  225. left: 30rpx;
  226. bottom: env(safe-area-inset-bottom);
  227. width: 690rpx;
  228. height: 80rpx;
  229. line-height: 80rpx;
  230. background: $uni-color-primary;
  231. border-radius: 46rpx;
  232. margin-top: 54rpx;
  233. font-size: 28rpx;
  234. color: #fff;
  235. }
  236. }
  237. }
  238. </style>