index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view>
  3. <view class="top">
  4. <image class="left-icon" :src="icon" mode="scaleToFill"></image>
  5. <text class="tit">100元话费,限时{{price}}元</text>
  6. </view>
  7. <view class="user-data">
  8. <van-cell-group>
  9. <van-field :value="tmallNo" @change='tmallNo_fieldChange' type="text" required clearable label="天猫订单号"
  10. icon="question-o" placeholder="请输入天猫订单号" @click-icon="onClickIcon('买了山泉心品才有的单号')" />
  11. <van-field :value="rechargePhoneNo" @change='rechargePhoneNo_fieldChange' type="number" label="手机号码"
  12. placeholder="请输入手机号码" required />
  13. </van-cell-group>
  14. </view>
  15. <view class="commodity-selection">
  16. <text class="top-tit">充值运营商类型</text>
  17. <view class="selection-box">
  18. <view class="commodity" :class="{selected:current==index}" @click="current=index"
  19. v-for="(item,index) in goodsInfoList" :key='index'>
  20. <text>{{item}}</text>
  21. <m-icon v-if="current==index" class="xuanzhong-icon" type="xuanzhong" color="#47CB79"></m-icon>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="prompt">
  26. <text class="top-tit">购买须知</text>
  27. <view class="dex-box">
  28. <text v-for="(item,index) in remark" :key='index'>{{index+1}}、{{item}}</text>
  29. </view>
  30. </view>
  31. <view class="buy-btn-box"></view>
  32. <view class="buy-btn" @click="buy">
  33. 立即充值
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data: () => ({
  40. current: 0,
  41. goodsInfoList: ['移动', '联通', '电信'],
  42. remark: ['请注意,买了就不给退钱'],
  43. tmallNo: null,
  44. rechargePhoneNo: null,
  45. icon: 'https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E5%A4%A9%E7%8C%AB%E6%B4%BB%E5%8A%A8%E8%AF%9D%E8%B4%B9.png',
  46. price: null
  47. }),
  48. async mounted() {
  49. let {
  50. data
  51. } = await this.$api.phoneBill.getPriceKeyword()
  52. this.price = data
  53. },
  54. methods: {
  55. async buy() {
  56. this.$utils.wxUtils.subscribeToNews().then(async res => {
  57. let orderRes = await this.$api.phoneBill.prepareOrder({
  58. tmallNo: this.tmallNo,
  59. rechargePhoneNo: this.rechargePhoneNo,
  60. operators: this.current + 1,
  61. goodsPictureUrl: this.icon,
  62. })
  63. let payRes = await wx.requestPayment(orderRes.data)
  64. if (payRes.errMsg == 'requestPayment:ok') {
  65. this.$utils.goPage(
  66. `/pages/phoneBill/orderdes?outTradeNo=${orderRes.data.outTradeNo}`,
  67. 'reLaunch')
  68. }
  69. })
  70. },
  71. tmallNo_fieldChange(e) {
  72. this.tmallNo = e.detail
  73. },
  74. rechargePhoneNo_fieldChange(e) {
  75. this.rechargePhoneNo = e.detail
  76. },
  77. onClickIcon(msg) {
  78. wx.showToast({
  79. title: msg,
  80. icon: 'none'
  81. })
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .top {
  88. margin-top: 20rpx;
  89. display: flex;
  90. justify-content: center;
  91. align-items: center;
  92. background-color: #FFFFFF;
  93. padding: 23rpx;
  94. .left-icon {
  95. width: 87rpx;
  96. height: 79rpx;
  97. margin-right: 22rpx;
  98. }
  99. .tit {
  100. white-space: nowrap;
  101. font-size: 30rpx;
  102. font-weight: 400;
  103. color: #0F0404;
  104. }
  105. }
  106. .user-data {
  107. background-color: #FFFFFF;
  108. display: flex;
  109. flex-direction: column;
  110. }
  111. .commodity-selection {
  112. margin-top: 20rpx;
  113. background-color: #FFFFFF;
  114. display: flex;
  115. flex-direction: column;
  116. .top-tit {
  117. font-size: 26rpx;
  118. font-weight: 400;
  119. color: #666666;
  120. line-height: 39rpx;
  121. border-bottom: 1rpx solid #e8e8e8;
  122. padding: 28rpx;
  123. }
  124. .selection-box {
  125. margin-top: 30rpx;
  126. display: flex;
  127. flex-wrap: wrap;
  128. justify-content: flex-start;
  129. padding-left: 15rpx;
  130. .selected {
  131. border: 1rpx solid #ECBF7A !important;
  132. background-color: #FDF3D7;
  133. }
  134. .commodity {
  135. margin-bottom: 15rpx;
  136. margin-right: 15rpx;
  137. width: 230rpx;
  138. display: flex;
  139. flex-direction: column;
  140. align-items: center;
  141. border: 1rpx solid #E8E8E8;
  142. box-sizing: border-box;
  143. padding: 30rpx 20rpx;
  144. border-radius: 6rpx;
  145. position: relative;
  146. .xuanzhong-icon {
  147. position: absolute;
  148. right: 0;
  149. bottom: 0;
  150. }
  151. text {
  152. &:nth-child(1) {
  153. color: #999999;
  154. font-size: 26rpx;
  155. }
  156. &:nth-child(2) {
  157. color: #999999;
  158. font-size: 26rpx;
  159. }
  160. &:nth-child(3) {
  161. color: #E31818;
  162. font-size: 40rpx;
  163. }
  164. &:nth-child(4) {
  165. color: #999999;
  166. font-size: 26rpx;
  167. text-decoration: line-through;
  168. }
  169. }
  170. }
  171. }
  172. }
  173. .prompt {
  174. margin-top: 20rpx;
  175. background-color: #FFFFFF;
  176. display: flex;
  177. flex-direction: column;
  178. .top-tit {
  179. font-size: 26rpx;
  180. font-weight: 400;
  181. color: #666666;
  182. line-height: 39rpx;
  183. border-bottom: 1rpx solid #e8e8e8;
  184. padding: 28rpx;
  185. }
  186. .dex-box {
  187. padding: 28rpx;
  188. display: flex;
  189. flex-direction: column;
  190. font-size: 26rpx;
  191. font-weight: 400;
  192. color: #666666;
  193. line-height: 39rpx;
  194. }
  195. }
  196. .buy-btn-box {
  197. margin-top: 30rpx;
  198. width: 600rpx;
  199. height: 80rpx;
  200. opacity: 0;
  201. }
  202. .buy-btn {
  203. position: fixed;
  204. bottom: 30rpx;
  205. left: 50%;
  206. transform: translateX(-50%);
  207. width: 600rpx;
  208. height: 80rpx;
  209. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  210. border-radius: 40rpx;
  211. font-size: 30rpx;
  212. font-weight: 400;
  213. color: #FFFFFF;
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. }
  218. </style>