paymentPopup.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. ¥9.9
  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>
  27. </view>
  28. <view class="row">
  29. <view class="label">抵扣(余额 <span class="price">0</span> )</view>
  30. <view class="value price">
  31. ¥0
  32. </view>
  33. </view>
  34. <view class="row">
  35. <view class="label"></view>
  36. <view class="value">
  37. 小计: <span class="price">¥9.9</span>
  38. </view>
  39. </view>
  40. <view class="tip">
  41. <radio class="radio" :checked="checkbox1" @click="checkbox1 = !checkbox1" />
  42. <span>我已阅读并同意 <span style="color: #FF8E21;">《用户协议》</span></span>
  43. </view>
  44. <view class="tip">
  45. <radio class="radio" :checked="checkbox2" @click="checkbox2 = !checkbox2" />
  46. <span>本人已满18岁且具备完全行为能力</span>
  47. </view>
  48. <image @click="submit" class="button" src="@/static/img/first/button5.png" mode="widthFix"></image>
  49. </view>
  50. </uni-popup>
  51. <!-- 抽赏结果 -->
  52. <uni-popup class="popup" ref="popup2" type="center">
  53. <view class="lotteryResults">
  54. <view class="title">
  55. 恭喜你抽中奖品
  56. <uni-icons class="close" @click="close2()" type="closeempty" size="20"></uni-icons>
  57. </view>
  58. <view class="prizes" v-if="prizes.length > 0">
  59. <view class="item" v-for="(item, index) in prizes">
  60. <view class="type">
  61. {{ $selectDictLabel(rewardType, item.prizeType) }}
  62. </view>
  63. <image class="img" :src="item.prizeIcon" mode="widthFix"></image>
  64. <view class="name">
  65. {{ item.prizeName }} × {{item.prizeNum}}
  66. </view>
  67. </view>
  68. </view>
  69. <Mloading text="抽奖中..." v-else />
  70. </view>
  71. </uni-popup>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. rewardType
  77. } from "@/utils/commonConfig.js"
  78. import {
  79. drawCardSubmitApi,
  80. submittResultApi
  81. } from "@/api/drawCard.js"
  82. import Mloading from "@/component/Mloading.vue"
  83. export default {
  84. components: {
  85. Mloading
  86. },
  87. emits:['callBack'],
  88. props: {
  89. value: {
  90. type: Object,
  91. default: {}
  92. },
  93. },
  94. data() {
  95. return {
  96. rewardType: rewardType,
  97. checkbox1: false,
  98. checkbox2: false,
  99. params: {
  100. raffleNumList: [],
  101. raffleId: null
  102. },
  103. orderId: null,
  104. prizes: [],
  105. getApiNum: 0,
  106. }
  107. },
  108. mounted() {
  109. // this.$refs.popup2.open('center')
  110. // this.getLotteryResults()
  111. },
  112. methods: {
  113. show(id, list) {
  114. console.log(list, 'list')
  115. this.params.raffleId = id
  116. this.params.raffleNumList = list
  117. this.$refs.popup.open('bottom')
  118. },
  119. close() {
  120. this.$refs.popup.close()
  121. },
  122. close2() {
  123. this.$refs.popup2.close()
  124. },
  125. submit() {
  126. this.params.couponId = 10
  127. let _this = this
  128. drawCardSubmitApi(this.params).then(res => {
  129. console.log(res, '提交购买卡牌')
  130. // 如果不需要付钱,直接进入抽卡结果
  131. if (res.data.orderStatus == 201) {
  132. _this.close()
  133. _this.$refs.popup2.open('center')
  134. _this.getLotteryResults(res)
  135. _this.$emit('callBack')
  136. return
  137. }
  138. this.orderId = res.data.orderId
  139. // 唤起支付
  140. this.wxPayment(res.data)
  141. })
  142. },
  143. getLotteryResults() {
  144. let params = {
  145. orderId: this.orderId,
  146. raffleId: this.params.raffleId,
  147. }
  148. submittResultApi(params).then(res => {
  149. console.log(res, 'res抽奖结果')
  150. this.prizes = res.data
  151. })
  152. },
  153. wxPayment(data) {
  154. let _this = this
  155. wx.requestPayment({
  156. 'timeStamp': data.timeStamp,
  157. 'nonceStr': data.nonceStr,
  158. 'package': data.packageValue,
  159. 'signType': data.signType,
  160. 'paySign': data.paySign,
  161. 'success': function(res) {
  162. console.log(res, "支付过程成功");
  163. _this.close()
  164. _this.$refs.popup2.open('center')
  165. _this.getLotteryResults(res)
  166. _this.$emit('callBack')
  167. },
  168. 'fail': function(res) {
  169. console.log("支付过程失败");
  170. util.showErrorToast('支付失败');
  171. },
  172. 'complete': function(res) {
  173. console.log("支付过程结束")
  174. }
  175. });
  176. },
  177. }
  178. }
  179. </script>
  180. <style scoped lang="scss">
  181. .popupContent {
  182. background-color: #F8F8F8;
  183. border-radius: 10px 10px 0 0;
  184. }
  185. .title {
  186. text-align: center;
  187. padding: 15px;
  188. font-weight: 600;
  189. .close {
  190. position: absolute;
  191. right: 15px;
  192. top: 15px;
  193. }
  194. }
  195. .row {
  196. margin: 10px 20px 0 20px;
  197. display: flex;
  198. justify-content: space-between;
  199. padding: 12px;
  200. background: #fff;
  201. border-radius: 6px;
  202. font-size: 14px;
  203. color: #666666;
  204. .price {
  205. color: #FF2C43;
  206. font-weight: 600;
  207. }
  208. .label {
  209. margin-right: 10px;
  210. }
  211. .number {
  212. display: flex;
  213. flex: 1;
  214. overflow: auto;
  215. max-width: 60%;
  216. // justify-content: flex-end;
  217. .item {
  218. width: 48px;
  219. height: 24px;
  220. background: #DDDDDD;
  221. border-radius: 51px;
  222. color: #000000;
  223. line-height: 24px;
  224. text-align: center;
  225. font-size: 12px;
  226. margin-right: 5px;
  227. flex-grow: 0;
  228. flex-shrink: 0;
  229. }
  230. }
  231. }
  232. .tip {
  233. margin: 10px 20px 0 20px;
  234. color: #000000;
  235. font-size: 12px;
  236. display: flex;
  237. align-items: center;
  238. .radio {
  239. transform: scale(0.7);
  240. }
  241. }
  242. .button {
  243. margin: 10px auto;
  244. width: 210px;
  245. }
  246. .lotteryResults {
  247. width: 90vw;
  248. background: #fff;
  249. border-radius: 10px;
  250. .prizes {
  251. padding: 10px;
  252. .item {
  253. display: inline-flex;
  254. flex-direction: column;
  255. align-items: center;
  256. justify-content: center;
  257. text-align: center;
  258. margin-right: 5px;
  259. .img {
  260. width: 70px;
  261. border-radius: 5px;
  262. }
  263. }
  264. }
  265. }
  266. </style>
  267. <style scoped>
  268. </style>