M_purchase.vue 6.7 KB

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