paymentPopup.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. drawCardSubmitApi(this.params).then(res => {
  127. console.log(res, '提交购买卡牌')
  128. this.orderId = res.data.orderId
  129. // 唤起支付
  130. this.wxPayment(res.data)
  131. })
  132. },
  133. getLotteryResults() {
  134. let params = {
  135. orderId: this.orderId,
  136. raffleId: this.params.raffleId,
  137. }
  138. submittResultApi(params).then(res => {
  139. console.log(res, 'res抽奖结果')
  140. this.prizes = res.data
  141. })
  142. },
  143. wxPayment(data) {
  144. let _this = this
  145. wx.requestPayment({
  146. 'timeStamp': data.timeStamp,
  147. 'nonceStr': data.nonceStr,
  148. 'package': data.packageValue,
  149. 'signType': data.signType,
  150. 'paySign': data.paySign,
  151. 'success': function(res) {
  152. console.log(res, "支付过程成功");
  153. _this.close()
  154. _this.$refs.popup2.open('center')
  155. _this.getLotteryResults(res)
  156. _this.$emit('callBack')
  157. },
  158. 'fail': function(res) {
  159. console.log("支付过程失败");
  160. util.showErrorToast('支付失败');
  161. },
  162. 'complete': function(res) {
  163. console.log("支付过程结束")
  164. }
  165. });
  166. },
  167. }
  168. }
  169. </script>
  170. <style scoped lang="scss">
  171. .popupContent {
  172. background-color: #F8F8F8;
  173. border-radius: 10px 10px 0 0;
  174. }
  175. .title {
  176. text-align: center;
  177. padding: 15px;
  178. font-weight: 600;
  179. .close {
  180. position: absolute;
  181. right: 15px;
  182. top: 15px;
  183. }
  184. }
  185. .row {
  186. margin: 10px 20px 0 20px;
  187. display: flex;
  188. justify-content: space-between;
  189. padding: 12px;
  190. background: #fff;
  191. border-radius: 6px;
  192. font-size: 14px;
  193. color: #666666;
  194. .price {
  195. color: #FF2C43;
  196. font-weight: 600;
  197. }
  198. .label {
  199. margin-right: 10px;
  200. }
  201. .number {
  202. display: flex;
  203. flex: 1;
  204. overflow: auto;
  205. max-width: 60%;
  206. // justify-content: flex-end;
  207. .item {
  208. width: 48px;
  209. height: 24px;
  210. background: #DDDDDD;
  211. border-radius: 51px;
  212. color: #000000;
  213. line-height: 24px;
  214. text-align: center;
  215. font-size: 12px;
  216. margin-right: 5px;
  217. flex-grow: 0;
  218. flex-shrink: 0;
  219. }
  220. }
  221. }
  222. .tip {
  223. margin: 10px 20px 0 20px;
  224. color: #000000;
  225. font-size: 12px;
  226. display: flex;
  227. align-items: center;
  228. .radio {
  229. transform: scale(0.7);
  230. }
  231. }
  232. .button {
  233. margin: 10px auto;
  234. width: 210px;
  235. }
  236. .lotteryResults {
  237. width: 90vw;
  238. background: #fff;
  239. border-radius: 10px;
  240. .prizes {
  241. padding: 10px;
  242. .item {
  243. display: inline-flex;
  244. flex-direction: column;
  245. align-items: center;
  246. justify-content: center;
  247. text-align: center;
  248. margin-right: 5px;
  249. .img {
  250. width: 70px;
  251. border-radius: 5px;
  252. }
  253. }
  254. }
  255. }
  256. </style>
  257. <style scoped>
  258. </style>