life.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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.num * 1 * pUser.recharge_discount*1*0.01).toFixed(2)}}
  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. import { passUser } from '@/api/zero.js'
  65. export default {
  66. data() {
  67. return {
  68. pUser: {},
  69. phone: '',
  70. info: [],
  71. content: '',
  72. choose: {
  73. goods_id: 0
  74. }
  75. }
  76. },
  77. onLoad() {},
  78. onShow() {
  79. this.passUser()
  80. },
  81. onReachBottom() {
  82. },
  83. onReady() {
  84. },
  85. onNavigationBarButtonTap(event) {
  86. console.log('nav button pressed', event)
  87. uni.navigateTo({
  88. url: '/pages/index/lifeOrder'
  89. })
  90. },
  91. methods: {
  92. passUser() {
  93. passUser().then(res => {
  94. this.pUser = res.data
  95. this.getCzList()
  96. })
  97. },
  98. goCz() {
  99. if (!this.phone) {
  100. return this.$api.msg('请输入手机号')
  101. }
  102. var pattern = /^1[0-9]{10}$/;
  103. if (!pattern.test(this.phone)) {
  104. return this.$api.msg('请输入正确的手机号')
  105. }
  106. if (!this.choose.goods_id) {
  107. return this.$api.msg('请选择需要充值的套餐')
  108. }
  109. this.$refs.popup.open()
  110. },
  111. goNew() {
  112. createCz({
  113. rechargeno: this.phone,
  114. pay_type: 'yue',
  115. goods_id: this.choose.goods_id,
  116. pay_price: (this.choose.num * 1 * this.pUser.recharge_discount*1*0.01).toFixed(2)
  117. }).then(res => {
  118. if(res.data.status == 'PAY_DEFICIENCY') {
  119. this.$api.msg(res.msg)
  120. }else {
  121. uni.showToast({
  122. icon: 'success',
  123. title: '充值成功'
  124. })
  125. }
  126. this.$refs.popup.close()
  127. })
  128. },
  129. chooseGood(item) {
  130. this.choose = item
  131. },
  132. getCzList() {
  133. let that = this
  134. getCzList().then(res => {
  135. this.info = res.data.data
  136. this.info.forEach(item => {
  137. if (item.goods.length > 0) {
  138. item.goods.forEach(itemt => {
  139. if (itemt.desc && itemt.desc.split('<p>').length > 1) {
  140. that.content = itemt.desc
  141. }
  142. })
  143. }
  144. })
  145. })
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .content {
  152. padding-top: 20rpx;
  153. padding-bottom: 20rpx;
  154. }
  155. .phone {
  156. width: 690rpx;
  157. height: 80rpx;
  158. background-color: #fff;
  159. border-radius: 220rpx;
  160. margin: 0 auto 20rpx;
  161. }
  162. .item-wrap {
  163. width: 690rpx;
  164. background-color: #fff;
  165. margin: 0 auto 20rpx;
  166. padding: 20rpx 34rpx;
  167. border-radius: 20rpx;
  168. .tip {
  169. width: 620rpx;
  170. margin: auto;
  171. background-color: #e9f1fe;
  172. padding: 20rpx;
  173. border-radius: 20rpx;
  174. margin-top: 40rpx;
  175. }
  176. .tit {
  177. font-size: 30rpx;
  178. font-weight: bold;
  179. }
  180. .item-list {
  181. justify-content: flex-start;
  182. padding-top: 40rpx;
  183. .item {
  184. width: 192rpx;
  185. border-radius: 20rpx;
  186. margin-right: 20rpx;
  187. background-color: #e9f1fe;
  188. text-align: center;
  189. padding: 40rpx 0;
  190. .num {
  191. color: #409EFF;
  192. font-weight: bold;
  193. font-size: 28rpx;
  194. }
  195. .base-price {
  196. padding-top: 10rpx;
  197. font-size: 22rpx;
  198. }
  199. .price {
  200. font-size: 28rpx;
  201. color: #f3253a;
  202. padding-top: 10rpx;
  203. }
  204. }
  205. .action {
  206. border: 1px solid #f3253a;
  207. }
  208. }
  209. }
  210. .top-search {
  211. height: 80rpx;
  212. padding: 0 20rpx;
  213. width: 100%;
  214. height: 116rpx;
  215. z-index: 99;
  216. .search {
  217. width: 24rpx;
  218. margin-right: 20rpx;
  219. }
  220. }
  221. .search-box {
  222. justify-content: flex-start;
  223. width: 690rpx;
  224. height: 72rpx;
  225. background: rgb(255, 255, 255);
  226. border-radius: 30rpx;
  227. padding: 0 10rpx 0 20rpx;
  228. margin: 0 auto 20rpx;
  229. input {
  230. flex-grow: 1;
  231. }
  232. .search-btn {
  233. flex-shrink: 0;
  234. width: 110rpx;
  235. height: 52rpx;
  236. text-align: center;
  237. line-height: 50rpx;
  238. color: #fff;
  239. background-color: $base-color;
  240. border-radius: 26rpx;
  241. }
  242. }
  243. .cz-model {
  244. width: 750rpx;
  245. background-color: #fff;
  246. padding: 60rpx 0 30rpx;
  247. text-align: center;
  248. border-radius: 25rpx 25rpx 0 0;
  249. view {
  250. padding: 10rpx 0;
  251. }
  252. .price {
  253. color: $base-color;
  254. font-size: 48rpx;
  255. font-weight: bold;
  256. }
  257. .tip {
  258. color: #409eff;
  259. }
  260. .tips {
  261. padding-bottom: 20rpx;
  262. }
  263. .btn {
  264. width: 690rpx;
  265. text-align: center;
  266. line-height: 60rpx;
  267. color: #fff;
  268. background-color: $base-color;
  269. border-radius: 40rpx;
  270. margin: auto;
  271. }
  272. }
  273. </style>