M_purchase.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view class="page">
  3. <view class="topBody">
  4. <view class="header">
  5. </view>
  6. <view class="myinfo">
  7. <view class="purchaseList" style="margin-top: 60rpx;">
  8. <view class="item" :class="index==sel?'itemSel':''" v-for="(item,index) in list"
  9. @click="selTA(item,index)">
  10. <view class="num1">
  11. <view class="name">{{ item.num_gmm }}M{{$t('txt.币')}}</view>
  12. </view>
  13. <view class="num2">
  14. <view class="name">{{ item.money }}{{$t('txt.¥')}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view style="padding-top: 20rpx;margin-left: 10rpx;" class="jinchu">
  19. <text style="color:#FFFFFF;font-size: 32rpx;font-weight: bold;">{{$t('txt.支付方式')}}</text>
  20. </view>
  21. <view class="mingxiList" @click="selPay('wechat')">
  22. <view class="left">
  23. <image class="icon" src="../../static/me/icon_wechat.png" mode="widthFix" />
  24. <text style="font-size: 28rpx;margin-left: 20rpx;color: #ffffff;">{{$t('txt.微信支付')}}</text>
  25. </view>
  26. <view class="right">
  27. <image class="icon"
  28. :src="payType=='wechat'?'../../static/me/icon_select.png':'../../static/me/icon_unsel.png'"
  29. mode="heightFix" />
  30. </view>
  31. </view>
  32. <!-- <view class="line"></view>
  33. <view class="mingxiList" @click="selPay('alipay')">
  34. <view class="left">
  35. <image class="icon" src="../../static/me/icon_alipay.png" mode="widthFix" />
  36. <text style="font-size: 28rpx;margin-left: 20rpx;color: #ffffff;">{{$t('txt.支付宝支付')}}</text>
  37. </view>
  38. <view class="right">
  39. <image class="icon"
  40. :src="payType=='alipay'?'../../static/me/icon_select.png':'../../static/me/icon_unsel.png'"
  41. mode="heightFix" />
  42. </view>
  43. </view -->>
  44. <view class="line"></view>
  45. <view class="btn_submit" @click="submitData">{{$t('txt.立即支付')}}{{$t('txt.¥')}}{{money}}</view>
  46. <view class="bottom" @click="goPage('/pages/AboutUs/pay_xy')">
  47. <text style="font-size: 28rpx;color: #FFFFFF;">{{$t('txt.点击支付即代表同意')}}</text>
  48. <text style="font-size: 28rpx;color: #FF2A95;">{{$t('txt.M币充值协议')}}</text>
  49. </view>
  50. </view>
  51. <view class="blankHeight"></view>
  52. </view>
  53. <!-- 提示框 -->
  54. <DialogBox ref="DialogBox"></DialogBox>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. components: {},
  60. data() {
  61. return {
  62. title: '',
  63. sel: 1,
  64. payType: 'wechat',
  65. list: [],
  66. money: 0,
  67. tid: 0,
  68. linkid: '',
  69. }
  70. },
  71. onLoad() {
  72. // setTimeout(function() {
  73. // uni.setNavigationBarColor({
  74. // frontColor: '#ffffff',
  75. // backgroundColor: '#00000000',
  76. // animation: {
  77. // duration: 400,
  78. // timingFunc: 'easeIn'
  79. // }
  80. // })
  81. // }, 200);
  82. },
  83. onShow() {
  84. this.loadData();
  85. let that = this;
  86. },
  87. methods: {
  88. onBack() {},
  89. goPage(page) {
  90. uni.navigateTo({
  91. url: page,
  92. })
  93. },
  94. selTA(item, se) {
  95. this.tid = item.id;
  96. this.sel = se;
  97. if (this.list != null && this.list != undefined) {
  98. this.money = this.list[se]['money'];
  99. }
  100. },
  101. selPay(se) {
  102. this.payType = se;
  103. },
  104. chkSel() {
  105. if (this.sel == 1) {
  106. this.sel = 0;
  107. } else {
  108. this.sel = 1;
  109. }
  110. },
  111. submitData() {
  112. // #ifdef H5
  113. uni.showToast({
  114. title: '请使用app充值',
  115. icon: "error"
  116. });
  117. return;
  118. // #endif
  119. let that = this;
  120. uni.request({
  121. url: this.$apiHost + '/Order/submit', //仅为示例,并非真实接口地址。
  122. data: {
  123. uuid: getApp().globalData.uuid,
  124. product_id: this.tid,
  125. type: 'buyM',
  126. payType: 'wechat'
  127. },
  128. header: {
  129. 'content-type': 'application/json' //自定义请求头信息
  130. },
  131. success: (res) => {
  132. console.log("res-pay", res.data);
  133. if (res.data.success == 'yes') {
  134. this.linkid = res.data.linkid;
  135. uni.requestPayment({
  136. "provider": "wxpay",
  137. "orderInfo": res.data.wepay,
  138. success(res) {
  139. console.log("res-suu:", res)
  140. setTimeout(function() {
  141. that.showPayCall();
  142. }, 1000);
  143. },
  144. fail(e) {
  145. console.log("fail", e);
  146. }
  147. });
  148. } else {
  149. uni.showToast({
  150. title: '创建订单失败,请联系客服',
  151. icon: "error"
  152. });
  153. }
  154. }
  155. });
  156. },
  157. showPayCall() {
  158. let that = this;
  159. this.$refs['DialogBox'].confirm({
  160. title: '提示',
  161. content: '我已经支付完成',
  162. DialogType: 'inquiry',
  163. btn1: '否',
  164. btn2: '是',
  165. animation: 0
  166. }).then((res) => {
  167. uni.request({
  168. url: this.$apiHost + "/Order/getstatus",
  169. data: {
  170. uuid: getApp().globalData.uuid,
  171. linkid: that.linkid
  172. },
  173. header: {
  174. "content-type": "application/json"
  175. },
  176. success: (res) => {
  177. if (res.data.success == "yes") {
  178. uni.showToast({
  179. title: '充值成功',
  180. icon: "none"
  181. });
  182. } else {
  183. uni.showToast({
  184. title: '还未检测到充值状态,请稍后再试',
  185. icon: "none"
  186. });
  187. setTimeout(function() {
  188. that.showPayCall();
  189. }, 1000);
  190. }
  191. },
  192. complete: (com) => {},
  193. });
  194. })
  195. },
  196. loadData() {
  197. var offset = (this.page - 1) * 20;
  198. uni.request({
  199. url: this.$apiHost + '/User/getCzList',
  200. data: {
  201. uuid: getApp().globalData.uuid
  202. },
  203. header: {
  204. 'content-type': 'application/json'
  205. },
  206. success: (res) => {
  207. console.log("res", res.data)
  208. this.num = res.data.num;
  209. if (res.data.list != null && res.data.list != undefined) {
  210. this.list = res.data.list;
  211. this.tid = this.list[1]['id'];
  212. this.sel = 1;
  213. this.money = this.list[1]['money'];
  214. }
  215. }
  216. });
  217. },
  218. }
  219. }
  220. </script>
  221. <style scoped lang="scss">
  222. @import 'M_purchase.scss';
  223. </style>