index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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*1*pUser.recharge_resumption*0.01).toFixed(0)}}复投积分 -->
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="item-wrap" v-if="content">
  26. <view class="tit">
  27. 注意事项
  28. </view>
  29. <view class="tip" v-html="content">
  30. </view>
  31. </view>
  32. <uni-popup ref="popup" type="bottom">
  33. <view class="cz-model">
  34. <view class="price">
  35. {{choose.num}}
  36. </view>
  37. <view class="">
  38. {{choose.goods_name}}
  39. </view>
  40. <view class="">
  41. 到账时间:1-96小时 (高峰期96小时内)
  42. </view>
  43. <view class="">
  44. 充值号码:<text class="tip">{{this.phone}}</text>
  45. </view>
  46. <view class="tip tips">
  47. 请仔细核对号码。输错号码后果自负
  48. </view>
  49. <view class="pay-type-list ">
  50. </view>
  51. <view class="btn" @click="goNew">
  52. 立即充值
  53. </view>
  54. </view>
  55. </uni-popup>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. getCzList,
  61. createCz
  62. } from '@/api/three'
  63. import {getUserInfo} from '@/api/user.js'
  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. payType: 3,
  76. payName: 'weixin',
  77. userInfo: {},
  78. }
  79. },
  80. onLoad() {
  81. this.getUserInfo()
  82. },
  83. onShow() {
  84. },
  85. onReachBottom() {
  86. },
  87. onReady() {
  88. },
  89. methods: {
  90. getUserInfo: function() {
  91. let that = this;
  92. getUserInfo().then(res => {
  93. that.userInfo = res.data
  94. });
  95. },
  96. //选择支付方式
  97. changePayType(type) {
  98. this.payType = type;
  99. if (this.payType == 1) {
  100. this.payName = 'weixin';
  101. }
  102. if (this.payType == 2) {
  103. this.payName = 'ali';
  104. }
  105. if (this.payType == 3) {
  106. this.payName = 'yue';
  107. }
  108. },
  109. goCz() {
  110. if (!this.phone) {
  111. return this.$api.msg('请输入手机号')
  112. }
  113. var pattern = /^1[0-9]{10}$/;
  114. if (!pattern.test(this.phone)) {
  115. return this.$api.msg('请输入正确的手机号')
  116. }
  117. if (!this.choose.goods_id) {
  118. return this.$api.msg('请选择需要充值的套餐')
  119. }
  120. // 校验手机
  121. let phoneType = this.getMobileOperator(this.phone)
  122. if(this.choose.goods_name.indexOf(phoneType) == -1) {
  123. this.choose = {}
  124. return uni.showModal({
  125. title: '温馨提醒',
  126. content: `您当前的手机号为${phoneType}号码,与充值套餐的运营商不一致,请重新选择套餐!`,
  127. showCancel:false
  128. })
  129. }
  130. this.$refs.popup.open()
  131. },
  132. getMobileOperator(phoneNumber) {
  133. // 移动号段
  134. var cmccPrefixes = ['134', '135', '136', '137', '138', '139', '150', '151', '152', '157', '158', '159', '182', '183', '184', '187', '188', '178', '147', '172', '198'];
  135. // 联通号段
  136. var cuccPrefixes = ['130', '131', '132', '155', '156', '185', '186', '145', '176', '175', '166'];
  137. // 电信号段
  138. var ctcPrefixes = ['133', '153', '180', '181', '189', '177', '173', '199'];
  139. // 虚拟运营商号段
  140. var virtualPrefixes = ['170', '171'];
  141. var prefix = phoneNumber.substring(0, 3);
  142. if (cmccPrefixes.includes(prefix)) {
  143. return '移动';
  144. } else if (cuccPrefixes.includes(prefix)) {
  145. return '联通';
  146. } else if (ctcPrefixes.includes(prefix)) {
  147. return '电信';
  148. } else if (virtualPrefixes.includes(prefix)) {
  149. return '虚拟运营商';
  150. } else {
  151. return '未知运营商';
  152. }
  153. },
  154. goNew() {
  155. let that = this
  156. createCz({
  157. rechargeno: this.phone,
  158. pay_type: this.payName,
  159. goods_id: this.choose.goods_id,
  160. pay_price: this.choose.num,
  161. price: this.choose.num
  162. }).then(res => {
  163. if(res.data.status == 'PAY_DEFICIENCY' ||res.data.status == 'PAY_ERROR') {
  164. this.$api.msg(res.msg)
  165. }else {
  166. }
  167. this.$refs.popup.close()
  168. })
  169. },
  170. chooseGood(item) {
  171. this.choose = item
  172. },
  173. getCzList() {
  174. let that = this
  175. getCzList().then(res => {
  176. this.info = res.data.data
  177. this.info.forEach(item => {
  178. if (item.goods.length > 0) {
  179. item.goods.forEach(itemt => {
  180. if (itemt.desc && itemt.desc.split('<p>').length > 1) {
  181. that.content = itemt.desc
  182. }
  183. })
  184. }
  185. })
  186. })
  187. },
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. .flex {
  193. display: flex;
  194. align-items: center;
  195. // justify-content: space-between;
  196. }
  197. .content {
  198. padding-top: 20rpx;
  199. padding-bottom: 20rpx;
  200. }
  201. .phone {
  202. width: 690rpx;
  203. height: 80rpx;
  204. background-color: #fff;
  205. border-radius: 220rpx;
  206. margin: 0 auto 20rpx;
  207. }
  208. .item-wrap {
  209. width: 690rpx;
  210. background-color: #fff;
  211. margin: 0 auto 20rpx;
  212. padding: 20rpx 34rpx;
  213. border-radius: 20rpx;
  214. .tip {
  215. width: 620rpx;
  216. margin: auto;
  217. background-color: #e9f1fe;
  218. padding: 20rpx;
  219. border-radius: 20rpx;
  220. margin-top: 40rpx;
  221. }
  222. .tit {
  223. font-size: 30rpx;
  224. font-weight: bold;
  225. }
  226. .item-list {
  227. justify-content: flex-start;
  228. padding-top: 40rpx;
  229. .item {
  230. // width: 192rpx;
  231. border-radius: 20rpx;
  232. margin-right: 20rpx;
  233. background-color: #e9f1fe;
  234. text-align: center;
  235. padding: 40rpx;
  236. .num {
  237. color: #409EFF;
  238. font-weight: bold;
  239. font-size: 28rpx;
  240. }
  241. .base-price {
  242. padding-top: 10rpx;
  243. font-size: 22rpx;
  244. }
  245. .price {
  246. font-size: 28rpx;
  247. color: #f3253a;
  248. padding-top: 10rpx;
  249. }
  250. }
  251. .action {
  252. border: 1px solid #f3253a;
  253. }
  254. }
  255. }
  256. .top-search {
  257. height: 80rpx;
  258. padding: 0 20rpx;
  259. width: 100%;
  260. height: 116rpx;
  261. z-index: 99;
  262. .search {
  263. width: 24rpx;
  264. margin-right: 20rpx;
  265. }
  266. }
  267. .search-box {
  268. justify-content: flex-start;
  269. width: 690rpx;
  270. height: 72rpx;
  271. background: rgb(255, 255, 255);
  272. border-radius: 30rpx;
  273. padding: 0 10rpx 0 20rpx;
  274. margin: 0 auto 20rpx;
  275. input {
  276. flex-grow: 1;
  277. height: 72rpx;
  278. line-height: 72rpx;
  279. }
  280. .search-btn {
  281. flex-shrink: 0;
  282. width: 110rpx;
  283. height: 52rpx;
  284. text-align: center;
  285. line-height: 50rpx;
  286. color: #fff;
  287. background-color: #409EFF;
  288. border-radius: 26rpx;
  289. }
  290. }
  291. .cz-model {
  292. width: 750rpx;
  293. background-color: #fff;
  294. padding: 60rpx 0 30rpx;
  295. text-align: center;
  296. border-radius: 25rpx 25rpx 0 0;
  297. view {
  298. padding: 10rpx 0;
  299. }
  300. .price {
  301. color: #409eff;
  302. font-size: 48rpx;
  303. font-weight: bold;
  304. }
  305. .tip {
  306. color: #409eff;
  307. }
  308. .tips {
  309. padding-bottom: 20rpx;
  310. }
  311. .btn {
  312. width: 690rpx;
  313. text-align: center;
  314. line-height: 60rpx;
  315. color: #fff;
  316. background-color: #409eff;
  317. border-radius: 40rpx;
  318. margin: auto;
  319. }
  320. }
  321. .pay-type-list {
  322. margin-top: 20upx;
  323. background-color: #fff;
  324. padding-left: 60upx;
  325. .type-item {
  326. height: 120upx;
  327. padding: 20upx 0;
  328. display: flex;
  329. justify-content: flex-start;
  330. align-items: center;
  331. padding-right: 60upx;
  332. font-size: 30upx;
  333. position: relative;
  334. }
  335. .icon {
  336. width: 100upx;
  337. font-size: 52upx;
  338. }
  339. .iconyue {
  340. color: #fe8e2e;
  341. }
  342. .iconweixin {
  343. color: #36cb59;
  344. }
  345. .iconzhifubao {
  346. color: #01aaef;
  347. }
  348. .tit {
  349. font-size: 28rpx;
  350. color: #000;
  351. margin-bottom: 4upx;
  352. }
  353. .con {
  354. flex: 1;
  355. display: flex;
  356. flex-direction: column;
  357. font-size: 26rpx;
  358. color: #000;
  359. }
  360. }
  361. </style>