life.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="content">
  3. <view class="search-box flex">
  4. <input type="text" v-model="phone" placeholder="输入手机号码" />
  5. <view class="search-btn" @click="goCz()">
  6. 充值
  7. </view>
  8. </view>
  9. <view class="item-wrap" v-for="item in info">
  10. <view class="tit">
  11. {{item.cname}}
  12. </view>
  13. <view class="item-list flex">
  14. <view class="item " v-for="itemt in item.goods" :class="{'action': itemt.goods_id == choose.goods_id}"
  15. @click="chooseGood(itemt)">
  16. <view class="num">
  17. {{itemt.num}}元
  18. </view>
  19. <view class="base-price">
  20. 官方¥{{itemt.num}}
  21. </view>
  22. <view class="price">
  23. ¥{{itemt.price}}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="item-wrap" v-if="content">
  29. <view class="tit">
  30. 注意事项
  31. </view>
  32. <view class="tip" v-html="content">
  33. </view>
  34. </view>
  35. <uni-popup ref="popup" type="bottom">
  36. <view class="cz-model">
  37. <view class="price">
  38. {{choose.price}}
  39. </view>
  40. <view class="">
  41. {{choose.goods_name}}
  42. </view>
  43. <view class="">
  44. 到账时间:1-96小时 (高峰期96小时内)
  45. </view>
  46. <view class="">
  47. 充值号码:<text class="tip">{{this.phone}}</text>
  48. </view>
  49. <view class="tip tips">
  50. 请仔细核对号码。输错号码后果自负
  51. </view>
  52. <view class="btn" @click="goNew">
  53. 立即充值
  54. </view>
  55. </view>
  56. </uni-popup>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. getCzList,
  62. createCz
  63. } from '@/api/three'
  64. export default {
  65. data() {
  66. return {
  67. phone: '',
  68. info: [],
  69. content: '',
  70. choose: {
  71. goods_id: 0
  72. }
  73. }
  74. },
  75. onLoad() {},
  76. onShow() {
  77. this.getCzList()
  78. },
  79. onReachBottom() {
  80. },
  81. onReady() {
  82. },
  83. onNavigationBarButtonTap(event) {
  84. console.log('nav button pressed', event)
  85. },
  86. methods: {
  87. goCz() {
  88. if (!this.phone) {
  89. return this.$api.msg('请输入手机号')
  90. }
  91. var pattern = /^1[0-9]{10}$/;
  92. if (!pattern.test(this.phone)) {
  93. return this.$api.msg('请输入正确的手机号')
  94. }
  95. if(!this.choose.goods_id) {
  96. return this.$api.msg('请选择需要充值的套餐')
  97. }
  98. this.$refs.popup.open()
  99. },
  100. goNew() {
  101. createCz({
  102. rechargeno: this.phone,
  103. pay_type: 'yue',
  104. goods_id: this.choose.goods_id
  105. }).then(res => {
  106. uni.showToast({
  107. icon:'success',
  108. title:'充值成功'
  109. })
  110. this.$refs.popup.close()
  111. })
  112. },
  113. chooseGood(item) {
  114. this.choose = item
  115. },
  116. getCzList() {
  117. let that = this
  118. getCzList().then(res => {
  119. this.info = res.data.data
  120. this.info.forEach(item => {
  121. if (item.goods.length > 0) {
  122. item.goods.forEach(itemt => {
  123. if (itemt.desc && itemt.desc.split('<p>').length > 1) {
  124. that.content = itemt.desc
  125. }
  126. })
  127. }
  128. })
  129. })
  130. },
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .content {
  136. padding-top: 20rpx;
  137. padding-bottom: 20rpx;
  138. }
  139. .phone {
  140. width: 690rpx;
  141. height: 80rpx;
  142. background-color: #fff;
  143. border-radius: 220rpx;
  144. margin: 0 auto 20rpx;
  145. }
  146. .item-wrap {
  147. width: 690rpx;
  148. background-color: #fff;
  149. margin: 0 auto 20rpx;
  150. padding: 20rpx 34rpx;
  151. border-radius: 20rpx;
  152. .tip {
  153. width: 620rpx;
  154. margin: auto;
  155. background-color: #e9f1fe;
  156. padding: 20rpx;
  157. border-radius: 20rpx;
  158. margin-top: 40rpx;
  159. }
  160. .tit {
  161. font-size: 30rpx;
  162. font-weight: bold;
  163. }
  164. .item-list {
  165. justify-content: flex-start;
  166. padding-top: 40rpx;
  167. .item {
  168. width: 192rpx;
  169. border-radius: 20rpx;
  170. margin-right: 20rpx;
  171. background-color: #e9f1fe;
  172. text-align: center;
  173. padding: 40rpx 0;
  174. .num {
  175. color: #409EFF;
  176. font-weight: bold;
  177. font-size: 28rpx;
  178. }
  179. .base-price {
  180. padding-top: 10rpx;
  181. font-size: 22rpx;
  182. }
  183. .price {
  184. font-size: 28rpx;
  185. color: #f3253a;
  186. padding-top: 10rpx;
  187. }
  188. }
  189. .action {
  190. border: 1px solid #f3253a;
  191. }
  192. }
  193. }
  194. .top-search {
  195. height: 80rpx;
  196. padding: 0 20rpx;
  197. width: 100%;
  198. height: 116rpx;
  199. z-index: 99;
  200. .search {
  201. width: 24rpx;
  202. margin-right: 20rpx;
  203. }
  204. }
  205. .search-box {
  206. justify-content: flex-start;
  207. width: 690rpx;
  208. height: 72rpx;
  209. background: rgb(255, 255, 255);
  210. border-radius: 30rpx;
  211. padding: 0 10rpx 0 20rpx;
  212. margin: 0 auto 20rpx;
  213. input {
  214. flex-grow: 1;
  215. }
  216. .search-btn {
  217. flex-shrink: 0;
  218. width: 110rpx;
  219. height: 52rpx;
  220. text-align: center;
  221. line-height: 50rpx;
  222. color: #fff;
  223. background-color: $base-color;
  224. border-radius: 26rpx;
  225. }
  226. }
  227. .cz-model {
  228. width: 750rpx;
  229. background-color: #fff;
  230. padding: 60rpx 0 30rpx;
  231. text-align: center;
  232. border-radius: 25rpx 25rpx 0 0;
  233. view {
  234. padding: 10rpx 0;
  235. }
  236. .price {
  237. color: $base-color;
  238. font-size: 48rpx;
  239. font-weight: bold;
  240. }
  241. .tip {
  242. color: #409eff ;
  243. }
  244. .tips {
  245. padding-bottom: 20rpx;
  246. }
  247. .btn {
  248. width: 690rpx;
  249. text-align: center;
  250. line-height: 60rpx;
  251. color: #fff;
  252. background-color: $base-color;
  253. border-radius: 40rpx;
  254. margin: auto;
  255. }
  256. }
  257. </style>