paymentPopup.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <view class="content">
  3. <uni-popup class="popup" ref="popup" type="bottom" background-color="#F8F8F8">
  4. <view class="popupContent">
  5. <view class="title">
  6. 购买卡牌
  7. <uni-icons class="close" @click="close()" type="closeempty" size="20"></uni-icons>
  8. </view>
  9. <view class="row">
  10. <view class="label">单价</view>
  11. <view class="value price">
  12. ¥{{ info.price || 0}}
  13. </view>
  14. </view>
  15. <view class="row">
  16. <view class="label">选中卡牌号码</view>
  17. <view class="value number">
  18. <view class="item" v-for="(item, index) in params.raffleNumList">
  19. {{item}}
  20. </view>
  21. </view>
  22. </view>
  23. <view class="row">
  24. <view class="label">优惠卷</view>
  25. <view class="value">
  26. <view v-if="!selestCouponId && couponList.length > 0" class="hasCoupon" @click="showPopup3">
  27. 选择优惠券
  28. <uni-icons type="right" color="#FF2C43" size="20"></uni-icons>
  29. </view>
  30. <view v-if="!selestCouponId && couponList.length == 0" class="noCoupon">
  31. 暂无可用优惠券
  32. </view>
  33. <view class="coupon price" v-if="selestCouponId">
  34. -¥{{selestCoupon.discount}}
  35. </view>
  36. </view>
  37. </view>
  38. <view class="row">
  39. <view class="label">抵扣(余额 <span class="price">0</span> )</view>
  40. <view class="value price">
  41. ¥0
  42. </view>
  43. </view>
  44. <view class="row">
  45. <view class="label"></view>
  46. <view class="value">
  47. 小计: <span class="price">¥{{ priceAll }}</span>
  48. </view>
  49. </view>
  50. <view class="tip">
  51. <radio class="radio" :checked="checkbox1" @click="checkbox1 = !checkbox1" />
  52. <span>我已阅读并同意 <span style="color: #FF8E21;">《用户协议》</span></span>
  53. </view>
  54. <view class="tip">
  55. <radio class="radio" :checked="checkbox2" @click="checkbox2 = !checkbox2" />
  56. <span>本人已满18岁且具备完全行为能力</span>
  57. </view>
  58. <image @click="submit" class="button" src="https://mall.rongtongh.cn/storage/img/first/button5.png" mode="widthFix"></image>
  59. </view>
  60. </uni-popup>
  61. <!-- 抽赏结果 -->
  62. <uni-popup class="popup" ref="popup2" type="center">
  63. <view class="lotteryResults">
  64. <view class="title">
  65. 恭喜你抽中奖品
  66. <uni-icons class="close" @click="close2()" type="closeempty" size="20"></uni-icons>
  67. </view>
  68. <view class="prizes" v-if="prizes.length > 0">
  69. <view class="item" v-for="(item, index) in prizes">
  70. <view class="type">
  71. {{ $selectDictLabel(rewardType, item.prizeType) }}
  72. </view>
  73. <image class="img" :src="item.prizeIcon" mode="widthFix"></image>
  74. <view class="name">
  75. {{ item.prizeName }} × {{item.prizeNum}}
  76. </view>
  77. </view>
  78. </view>
  79. <Mloading text="抽奖中..." v-else />
  80. </view>
  81. </uni-popup>
  82. <!-- 选则优惠券 -->
  83. <uni-popup class="popup" ref="popup3" type="bottom" background-color="#F8F8F8">
  84. <view class="popupContent">
  85. <view class="title">
  86. <!-- 选择优惠券 -->
  87. <uni-icons class="close" @click="close3()" type="closeempty" size="20"></uni-icons>
  88. </view>
  89. </view>
  90. <view class="popupList">
  91. <view class="card" v-for="(item, index) in couponList" @click="clickSelestCoupon(item)">
  92. <view class="leftIcon"></view>
  93. <view class="left">
  94. ¥<span style="font-size: 18px;">{{item.discount}}</span>
  95. </view>
  96. <view class="right">
  97. <view class="row title">
  98. {{item.name}}
  99. </view>
  100. <view class="row endTime">
  101. {{item.endTime}}到期
  102. </view>
  103. <view class="row desc">
  104. {{item.desc}}
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </uni-popup>
  110. </view>
  111. </template>
  112. <script>
  113. import {
  114. rewardType
  115. } from "@/utils/commonConfig.js"
  116. import {
  117. couponListApi
  118. } from "@/api/coupon.js"
  119. import {
  120. drawCardSubmitApi,
  121. submittResultApi,
  122. orderPriceApi
  123. } from "@/api/drawCard.js"
  124. import Mloading from "@/component/Mloading.vue"
  125. export default {
  126. components: {
  127. Mloading
  128. },
  129. emits: ['callBack'],
  130. props: {
  131. value: {
  132. type: Object,
  133. default: {}
  134. },
  135. },
  136. computed: {
  137. },
  138. data() {
  139. return {
  140. priceAll: 0,
  141. rewardType: rewardType,
  142. checkbox1: false,
  143. checkbox2: false,
  144. params: {
  145. raffleNumList: [],
  146. raffleId: null
  147. },
  148. orderId: null,
  149. prizes: [],
  150. getApiNum: 0,
  151. info: {},
  152. // 优惠券
  153. couponList: [],
  154. // 选中的优惠券
  155. selestCouponId: null,
  156. selestCoupon: {}
  157. }
  158. },
  159. mounted() {
  160. // this.$refs.popup2.open('center')
  161. // this.getLotteryResults()
  162. },
  163. methods: {
  164. getPrice() {
  165. let params = {
  166. orderNum: this.params.raffleNumList.length,
  167. orderThirdId: this.params.raffleId,
  168. orderType: 1,
  169. userCouponId: this.selestCouponId || ''
  170. }
  171. orderPriceApi(params).then(res => {
  172. console.log(res, '订单价格')
  173. this.priceAll = res.data
  174. })
  175. },
  176. show(id, list, info) {
  177. this.refresh()
  178. console.log(list, 'list')
  179. this.params.raffleId = id
  180. this.params.raffleNumList = list
  181. this.info = info
  182. this.$refs.popup.open('bottom')
  183. //计算订单价格
  184. this.getPrice()
  185. // 获取优惠券列表
  186. this.getCoupon()
  187. },
  188. refresh() {
  189. // 刷新组件状态
  190. this.selestCouponId = null,
  191. this.selestCoupon = {}
  192. this.prizes = []
  193. this.checkbox1 = false
  194. this.checkbox2 = false
  195. this.orderId = null
  196. },
  197. close() {
  198. this.$refs.popup.close()
  199. },
  200. close2() {
  201. this.$refs.popup2.close()
  202. },
  203. showPopup3() {
  204. // if (this.couponList.length > 0) {
  205. this.$refs.popup3.open()
  206. // }
  207. },
  208. close3() {
  209. this.$refs.popup3.close()
  210. },
  211. // 获取优惠券
  212. getCoupon() {
  213. let params = {
  214. limit: 999,
  215. page: 1,
  216. status: 0,
  217. raffleId: this.params.raffleId
  218. }
  219. couponListApi(params).then(res => {
  220. this.couponList = res.data.list
  221. })
  222. },
  223. // 选择优惠券
  224. clickSelestCoupon(item) {
  225. this.selestCoupon = item
  226. this.selestCouponId = item.id
  227. this.getPrice()
  228. this.close3()
  229. },
  230. submit() {
  231. let _this = this
  232. if (this.selestCouponId) {
  233. this.params.couponId = this.selestCouponId
  234. }
  235. drawCardSubmitApi(this.params).then(res => {
  236. console.log(res, '提交购买卡牌')
  237. this.orderId = res.data.orderId
  238. // 如果不需要付钱,直接进入抽卡结果
  239. if (res.data.orderStatus == 201) {
  240. _this.close()
  241. _this.$refs.popup2.open('center')
  242. _this.getLotteryResults(res)
  243. _this.$emit('callBack')
  244. return
  245. }
  246. // 唤起支付
  247. this.wxPayment(res.data)
  248. })
  249. },
  250. getLotteryResults() {
  251. let params = {
  252. orderId: this.orderId,
  253. raffleId: this.params.raffleId,
  254. }
  255. submittResultApi(params).then(res => {
  256. console.log(res, 'res抽奖结果')
  257. this.prizes = res.data
  258. })
  259. },
  260. wxPayment(data) {
  261. let _this = this
  262. wx.requestPayment({
  263. 'timeStamp': data.timeStamp,
  264. 'nonceStr': data.nonceStr,
  265. 'package': data.packageValue,
  266. 'signType': data.signType,
  267. 'paySign': data.paySign,
  268. 'success': function(res) {
  269. console.log(res, "支付过程成功");
  270. _this.close()
  271. _this.$refs.popup2.open('center')
  272. _this.getLotteryResults(res)
  273. _this.$emit('callBack')
  274. },
  275. 'fail': function(res) {
  276. console.log("支付过程失败");
  277. util.showErrorToast('支付失败');
  278. },
  279. 'complete': function(res) {
  280. console.log("支付过程结束")
  281. }
  282. });
  283. },
  284. }
  285. }
  286. </script>
  287. <style scoped lang="scss">
  288. .popupContent {
  289. background-color: #F8F8F8;
  290. border-radius: 10px 10px 0 0;
  291. >.row {
  292. margin: 10px 20px 0 20px;
  293. display: flex;
  294. justify-content: space-between;
  295. padding: 12px;
  296. background: #fff;
  297. border-radius: 6px;
  298. font-size: 14px;
  299. color: #666666;
  300. .price {
  301. color: #FF2C43;
  302. font-weight: 600;
  303. }
  304. .label {
  305. margin-right: 10px;
  306. }
  307. .number {
  308. display: flex;
  309. flex: 1;
  310. overflow: auto;
  311. max-width: 60%;
  312. // justify-content: flex-end;
  313. .item {
  314. width: 48px;
  315. height: 24px;
  316. background: #DDDDDD;
  317. border-radius: 51px;
  318. color: #000000;
  319. line-height: 24px;
  320. text-align: center;
  321. font-size: 12px;
  322. margin-right: 5px;
  323. flex-grow: 0;
  324. flex-shrink: 0;
  325. }
  326. }
  327. .value {
  328. .hasCoupon {
  329. display: flex;
  330. align-items: center;
  331. color: #FF2C43;
  332. font-size: 12px;
  333. }
  334. .noCoupon {
  335. display: flex;
  336. align-items: center;
  337. color: #8c8c8c;
  338. font-size: 12px;
  339. }
  340. }
  341. }
  342. > .title {
  343. text-align: center;
  344. padding: 15px;
  345. font-weight: 600;
  346. .close {
  347. position: absolute;
  348. right: 15px;
  349. top: 15px;
  350. }
  351. }
  352. }
  353. .tip {
  354. margin: 10px 20px 0 20px;
  355. color: #000000;
  356. font-size: 12px;
  357. display: flex;
  358. align-items: center;
  359. .radio {
  360. transform: scale(0.7);
  361. }
  362. }
  363. .button {
  364. margin: 10px auto;
  365. width: 210px;
  366. }
  367. .lotteryResults {
  368. width: 90vw;
  369. background: #fff;
  370. border-radius: 10px;
  371. > .title {
  372. text-align: center;
  373. padding: 15px;
  374. font-weight: 600;
  375. .close {
  376. position: absolute;
  377. right: 15px;
  378. top: 15px;
  379. }
  380. }
  381. .prizes {
  382. padding: 10px;
  383. .item {
  384. display: inline-flex;
  385. flex-direction: column;
  386. align-items: center;
  387. justify-content: center;
  388. text-align: center;
  389. margin-right: 5px;
  390. .img {
  391. width: 70px;
  392. border-radius: 5px;
  393. }
  394. }
  395. }
  396. }
  397. .popupList {
  398. max-height: 50vh;
  399. min-height: 30vh;
  400. overflow: auto;
  401. background: #F8F8F8;
  402. padding: 10px;
  403. .card {
  404. background: #fff;
  405. border-radius: 8px;
  406. overflow: hidden;
  407. display: flex;
  408. .leftIcon {
  409. height: auto;
  410. width: 8px;
  411. background: #FF2C43;
  412. }
  413. .left {
  414. width: 80px;
  415. display: inline-flex;
  416. justify-content: center;
  417. align-items: center;
  418. color: #FF2C43;
  419. font-weight: 600;
  420. }
  421. .right {
  422. padding: 10px;
  423. .row {
  424. margin-bottom: 4px;
  425. font-size: 12px;
  426. }
  427. .title {
  428. font-size: 14px;
  429. font-weight: 600;
  430. }
  431. .endTime {
  432. color: #FF2C43;
  433. }
  434. .desc {
  435. margin-top: 5px;
  436. color: #8c8c8c;
  437. }
  438. }
  439. }
  440. }
  441. </style>
  442. <style scoped>
  443. </style>