M_purchase.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="page">
  3. <view class="topBody">
  4. <PageHeader title="会员" class="PageHeader">
  5. <template slot="right">
  6. <DropdownMenu
  7. :options="dropdownOptions"
  8. @select="handleDropdownSelect"
  9. />
  10. </template>
  11. </PageHeader>
  12. <view class="reserveASeat"></view>
  13. <view class="myGoldCoin-box">
  14. <view>我的M币</view>
  15. <view class="myGoldCoin-box-content">
  16. <image src="../../static/icon/coin_m.png" mode="widthFix" />
  17. <text>{{ myGoldCoin }}</text>
  18. </view>
  19. </view>
  20. <view class="myinfo">
  21. <view class="purchaseList" style="margin-top: 60rpx">
  22. <view
  23. class="item"
  24. :class="index == sel ? 'itemSel' : ''"
  25. v-for="(item, index) in list"
  26. @click="selTA(item, index)"
  27. :key="index"
  28. >
  29. <view class="num1">
  30. <image src="../../static/icon/coin_m.png" mode="widthFix" />
  31. <view class="name">{{ item.num_gmm| formatNumberToK }} </view>
  32. </view>
  33. <view class="num2">
  34. <view class="name">{{ item.money }}{{ $t("txt.¥") }}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="jinchu">
  39. <text>{{ $t("txt.支付方式") }}</text>
  40. </view>
  41. <view v-if="false" class="mingxiList" @click="selPay('wechat')">
  42. <view class="left">
  43. <image
  44. class="icon"
  45. src="../../static/me/icon_wechat.png"
  46. mode="widthFix"
  47. />
  48. <text style="font-size: 28rpx; margin-left: 20rpx">{{
  49. $t("txt.微信支付")
  50. }}</text>
  51. </view>
  52. <view class="right">
  53. <image
  54. class="icon"
  55. :src="
  56. payType == 'wechat'
  57. ? '../../static/icon/wd_icon_gouxuan04.png'
  58. : '../../static/icon/wd_icon_gouxuan05.png'
  59. "
  60. mode="heightFix"
  61. />
  62. </view>
  63. </view>
  64. <!-- <view class="line"></view> -->
  65. <view class="mingxiList" @click="selPay('alipay')">
  66. <view class="left">
  67. <image
  68. class="icon"
  69. src="../../static/me/icon_alipay.png"
  70. mode="widthFix"
  71. />
  72. <text style="font-size: 28rpx; margin-left: 20rpx">{{
  73. $t("txt.支付宝支付")
  74. }}</text>
  75. </view>
  76. <view class="right">
  77. <image
  78. class="icon"
  79. :src="
  80. payType == 'alipay'
  81. ? '../../static/icon/wd_icon_gouxuan04.png'
  82. : '../../static/icon/wd_icon_gouxuan05.png'
  83. "
  84. mode="heightFix"
  85. />
  86. </view>
  87. </view>
  88. <!-- <view class="line"></view> -->
  89. <view class="agree">
  90. <view class="agree2" @click="agreeChk()">
  91. <image
  92. mode="widthFix"
  93. src="../../static/icon/wd_icon_gouxuan04.png"
  94. v-if="is_agree == 0"
  95. ></image>
  96. <image
  97. mode="widthFix"
  98. src="../../static/icon/wd_icon_gouxuan05.png"
  99. v-if="is_agree == 1"
  100. ></image>
  101. </view>
  102. <view>
  103. 同意
  104. <text class="xy" @click="goPage('/pages/AboutUs/pay_xy')">
  105. 《充值服务协议》 </text
  106. >,充值M币仅【萌创星球】使用点击查看
  107. <text class="xy" @click="goPage('yszc')"> 充值记录 </text>
  108. </view>
  109. </view>
  110. <view class="btn_submit" @click="submitData">
  111. <text>¥{{ money }}</text
  112. >确认充值
  113. </view>
  114. </view>
  115. <view class="blankHeight"></view>
  116. </view>
  117. <!-- 提示框 -->
  118. <DialogBox ref="DialogBox"></DialogBox>
  119. </view>
  120. </template>
  121. <script>
  122. import DropdownMenu from '@/components/DropdownMenu.vue'
  123. export default {
  124. components: {
  125. DropdownMenu
  126. },
  127. data() {
  128. return {
  129. title: "",
  130. sel: 1,
  131. payType: "wechat",
  132. list: [],
  133. money: 0,
  134. tid: 0,
  135. linkid: "",
  136. is_agree: 0,
  137. myGoldCoin: 0,
  138. dropdownOptions: [
  139. { label: '购买记录', type: 'vipRecord' }
  140. ]
  141. };
  142. },
  143. onLoad() {
  144. // setTimeout(function() {
  145. // uni.setNavigationBarColor({
  146. // frontColor: '#ffffff',
  147. // backgroundColor: '#00000000',
  148. // animation: {
  149. // duration: 400,
  150. // timingFunc: 'easeIn'
  151. // }
  152. // })
  153. // }, 200);
  154. },
  155. onShow() {
  156. this.loadData();
  157. let that = this;
  158. },
  159. methods: {
  160. onBack() {},
  161. goPage(page) {
  162. uni.navigateTo({
  163. url: page,
  164. });
  165. },
  166. selTA(item, se) {
  167. this.tid = item.id;
  168. this.sel = se;
  169. if (this.list != null && this.list != undefined) {
  170. this.money = this.list[se]["money"];
  171. }
  172. },
  173. selPay(se) {
  174. this.payType = se;
  175. },
  176. chkSel() {
  177. if (this.sel == 1) {
  178. this.sel = 0;
  179. } else {
  180. this.sel = 1;
  181. }
  182. },
  183. submitData() {
  184. if (this.is_agree == 0) {
  185. uni.showToast({
  186. title: "请确认并选择协议",
  187. icon: "none",
  188. });
  189. return;
  190. }
  191. let that = this;
  192. uni.request({
  193. url: this.$apiHost + "/Order/submit",
  194. data: {
  195. uuid: getApp().globalData.uuid,
  196. product_id: this.tid,
  197. type: "buyM",
  198. payType: this.payType,
  199. },
  200. header: {
  201. "content-type": "application/json",
  202. },
  203. success: (res) => {
  204. console.log("res-pay", res.data);
  205. if (res.data.success == "yes") {
  206. this.linkid = res.data.linkid;
  207. // 微信支付逻辑
  208. if (this.payType === "wechat") {
  209. uni.requestPayment({
  210. provider: "wxpay",
  211. orderInfo: {
  212. appid: res.data.wepay.appid,
  213. partnerid: res.data.wepay.partnerid,
  214. prepayid: res.data.wepay.prepayid,
  215. package: "Sign=WXPay",
  216. noncestr: res.data.wepay.noncestr,
  217. timestamp: res.data.wepay.timestamp,
  218. sign: res.data.wepay.sign
  219. },
  220. success(res) {
  221. console.log("微信支付成功:", res);
  222. setTimeout(function () {
  223. that.showPayCall();
  224. }, 1000);
  225. },
  226. fail(e) {
  227. console.log("微信支付失败:", e);
  228. uni.showToast({
  229. title: "支付失败,请重试",
  230. icon: "none"
  231. });
  232. }
  233. });
  234. }
  235. // 支付宝支付逻辑
  236. else if (this.payType === "alipay") {
  237. uni.requestPayment({
  238. provider: "alipay",
  239. orderInfo: res.data.ali_pay, // 直接使用后端返回的支付宝支付参数
  240. success(res) {
  241. console.log("支付宝支付成功:", res);
  242. setTimeout(function () {
  243. that.showPayCall();
  244. }, 1000);
  245. },
  246. fail(e) {
  247. console.log("支付宝支付失败:", e);
  248. uni.showToast({
  249. title: "支付失败,请重试",
  250. icon: "none"
  251. });
  252. }
  253. });
  254. }
  255. } else {
  256. uni.showToast({
  257. title: "创建订单失败,请联系客服",
  258. icon: "error",
  259. });
  260. }
  261. },
  262. fail: (err) => {
  263. console.log("请求失败:", err);
  264. uni.showToast({
  265. title: "网络错误,请重试",
  266. icon: "none"
  267. });
  268. }
  269. });
  270. },
  271. showPayCall() {
  272. let that = this;
  273. this.$refs["DialogBox"]
  274. .confirm({
  275. title: "提示",
  276. content: "我已经支付完成",
  277. DialogType: "inquiry",
  278. btn1: "否",
  279. btn2: "是",
  280. animation: 0,
  281. })
  282. .then((res) => {
  283. uni.request({
  284. url: this.$apiHost + "/Order/getstatus",
  285. data: {
  286. uuid: getApp().globalData.uuid,
  287. linkid: that.linkid,
  288. },
  289. header: {
  290. "content-type": "application/json",
  291. },
  292. success: (res) => {
  293. if (res.data.success == "yes") {
  294. uni.showToast({
  295. title: "充值成功",
  296. icon: "none",
  297. });
  298. } else {
  299. uni.showToast({
  300. title: "还未检测到充值状态,请稍后再试",
  301. icon: "none",
  302. });
  303. setTimeout(function () {
  304. that.showPayCall();
  305. }, 1000);
  306. }
  307. },
  308. complete: (com) => {},
  309. });
  310. });
  311. },
  312. loadData() {
  313. // 获取M币数量
  314. uni.request({
  315. url: this.$apiHost + '/My/getnum',
  316. method: 'GET',
  317. header: {
  318. 'content-type': 'application/json',
  319. 'sign': getApp().globalData.headerSign
  320. },
  321. data: {
  322. uuid: getApp().globalData.uuid
  323. },
  324. success: (res) => {
  325. console.log("获取用户M币数量:", res.data);
  326. if (res.data && res.data.num_gmm) {
  327. this.myGoldCoin = res.data.num_gmm;
  328. }
  329. }
  330. });
  331. // 获取充值列表
  332. uni.request({
  333. url: this.$apiHost + "/User/getCzList",
  334. data: {
  335. uuid: getApp().globalData.uuid,
  336. },
  337. header: {
  338. "content-type": "application/json",
  339. },
  340. success: (res) => {
  341. console.log("res", res.data);
  342. this.num = res.data.num;
  343. if (res.data.list != null && res.data.list != undefined) {
  344. this.list = res.data.list;
  345. this.tid = this.list[1]["id"];
  346. this.sel = 1;
  347. this.money = this.list[1]["money"];
  348. }
  349. },
  350. });
  351. },
  352. handleDropdownSelect(item) {
  353. switch (item.type) {
  354. case "vipRecord":
  355. uni.navigateTo({
  356. url: "/pages/vip/record?type=coin",
  357. });
  358. break;
  359. }
  360. },
  361. agreeChk() {
  362. if (this.is_agree == 0) {
  363. this.is_agree = 1;
  364. } else {
  365. this.is_agree = 0;
  366. }
  367. },
  368. },
  369. };
  370. </script>
  371. <style scoped lang="scss">
  372. @import "M_purchase.scss";
  373. .agree {
  374. width: 90%;
  375. margin: 0 auto;
  376. color: #666666;
  377. font-size: 24rpx;
  378. margin-top: 40rpx;
  379. display: flex;
  380. align-items: center;
  381. text-align: left;
  382. line-height: 32rpx;
  383. .agree2 {
  384. display: flex;
  385. flex-direction: row;
  386. justify-content: flex-start;
  387. align-items: center;
  388. padding-right: 8rpx;
  389. flex-shrink: 0;
  390. }
  391. .xy {
  392. color: #0084ff;
  393. display: inline;
  394. }
  395. image {
  396. width: 32rpx;
  397. height: 32rpx;
  398. }
  399. }
  400. .btn_submit {
  401. width: 626rpx;
  402. height: 88rpx;
  403. background: linear-gradient(90deg, #1f1f1f 0%, #444444 100%);
  404. border-radius: 76rpx;
  405. margin: 0 auto;
  406. margin-top: 70rpx;
  407. color: #acf934;
  408. display: flex;
  409. align-items: center;
  410. justify-content: center;
  411. font-size: 32rpx;
  412. line-height: 0;
  413. text {
  414. font-size: 44rpx;
  415. display: inline-block;
  416. margin-right: 10rpx;
  417. }
  418. }
  419. </style>