M_purchase.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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>1000</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 }} </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. dropdownOptions: [
  138. { label: '购买记录', type: 'vipRecord' }
  139. ]
  140. };
  141. },
  142. onLoad() {
  143. // setTimeout(function() {
  144. // uni.setNavigationBarColor({
  145. // frontColor: '#ffffff',
  146. // backgroundColor: '#00000000',
  147. // animation: {
  148. // duration: 400,
  149. // timingFunc: 'easeIn'
  150. // }
  151. // })
  152. // }, 200);
  153. },
  154. onShow() {
  155. this.loadData();
  156. let that = this;
  157. },
  158. methods: {
  159. onBack() {},
  160. goPage(page) {
  161. uni.navigateTo({
  162. url: page,
  163. });
  164. },
  165. selTA(item, se) {
  166. this.tid = item.id;
  167. this.sel = se;
  168. if (this.list != null && this.list != undefined) {
  169. this.money = this.list[se]["money"];
  170. }
  171. },
  172. selPay(se) {
  173. this.payType = se;
  174. },
  175. chkSel() {
  176. if (this.sel == 1) {
  177. this.sel = 0;
  178. } else {
  179. this.sel = 1;
  180. }
  181. },
  182. submitData() {
  183. if (this.is_agree == 0) {
  184. uni.showToast({
  185. title: "请确认并选择协议",
  186. icon: "none",
  187. });
  188. return;
  189. }
  190. let that = this;
  191. uni.request({
  192. url: this.$apiHost + "/Order/submit",
  193. data: {
  194. uuid: getApp().globalData.uuid,
  195. product_id: this.tid,
  196. type: "buyM",
  197. payType: this.payType,
  198. },
  199. header: {
  200. "content-type": "application/json",
  201. },
  202. success: (res) => {
  203. console.log("res-pay", res.data);
  204. if (res.data.success == "yes") {
  205. this.linkid = res.data.linkid;
  206. // 微信支付逻辑
  207. if (this.payType === "wechat") {
  208. uni.requestPayment({
  209. provider: "wxpay",
  210. orderInfo: {
  211. appid: res.data.wepay.appid,
  212. partnerid: res.data.wepay.partnerid,
  213. prepayid: res.data.wepay.prepayid,
  214. package: "Sign=WXPay",
  215. noncestr: res.data.wepay.noncestr,
  216. timestamp: res.data.wepay.timestamp,
  217. sign: res.data.wepay.sign
  218. },
  219. success(res) {
  220. console.log("微信支付成功:", res);
  221. setTimeout(function () {
  222. that.showPayCall();
  223. }, 1000);
  224. },
  225. fail(e) {
  226. console.log("微信支付失败:", e);
  227. uni.showToast({
  228. title: "支付失败,请重试",
  229. icon: "none"
  230. });
  231. }
  232. });
  233. }
  234. // 支付宝支付逻辑
  235. else if (this.payType === "alipay") {
  236. uni.requestPayment({
  237. provider: "alipay",
  238. orderInfo: res.data.ali_pay, // 直接使用后端返回的支付宝支付参数
  239. success(res) {
  240. console.log("支付宝支付成功:", res);
  241. setTimeout(function () {
  242. that.showPayCall();
  243. }, 1000);
  244. },
  245. fail(e) {
  246. console.log("支付宝支付失败:", e);
  247. uni.showToast({
  248. title: "支付失败,请重试",
  249. icon: "none"
  250. });
  251. }
  252. });
  253. }
  254. } else {
  255. uni.showToast({
  256. title: "创建订单失败,请联系客服",
  257. icon: "error",
  258. });
  259. }
  260. },
  261. fail: (err) => {
  262. console.log("请求失败:", err);
  263. uni.showToast({
  264. title: "网络错误,请重试",
  265. icon: "none"
  266. });
  267. }
  268. });
  269. },
  270. showPayCall() {
  271. let that = this;
  272. this.$refs["DialogBox"]
  273. .confirm({
  274. title: "提示",
  275. content: "我已经支付完成",
  276. DialogType: "inquiry",
  277. btn1: "否",
  278. btn2: "是",
  279. animation: 0,
  280. })
  281. .then((res) => {
  282. uni.request({
  283. url: this.$apiHost + "/Order/getstatus",
  284. data: {
  285. uuid: getApp().globalData.uuid,
  286. linkid: that.linkid,
  287. },
  288. header: {
  289. "content-type": "application/json",
  290. },
  291. success: (res) => {
  292. if (res.data.success == "yes") {
  293. uni.showToast({
  294. title: "充值成功",
  295. icon: "none",
  296. });
  297. } else {
  298. uni.showToast({
  299. title: "还未检测到充值状态,请稍后再试",
  300. icon: "none",
  301. });
  302. setTimeout(function () {
  303. that.showPayCall();
  304. }, 1000);
  305. }
  306. },
  307. complete: (com) => {},
  308. });
  309. });
  310. },
  311. loadData() {
  312. var offset = (this.page - 1) * 20;
  313. uni.request({
  314. url: this.$apiHost + "/User/getCzList",
  315. data: {
  316. uuid: getApp().globalData.uuid,
  317. },
  318. header: {
  319. "content-type": "application/json",
  320. },
  321. success: (res) => {
  322. console.log("res", res.data);
  323. this.num = res.data.num;
  324. if (res.data.list != null && res.data.list != undefined) {
  325. this.list = res.data.list;
  326. this.tid = this.list[1]["id"];
  327. this.sel = 1;
  328. this.money = this.list[1]["money"];
  329. }
  330. },
  331. });
  332. },
  333. handleDropdownSelect(item) {
  334. switch (item.type) {
  335. case "vipRecord":
  336. uni.navigateTo({
  337. url: "/pages/vip/record?type=coin",
  338. });
  339. break;
  340. }
  341. },
  342. agreeChk() {
  343. if (this.is_agree == 0) {
  344. this.is_agree = 1;
  345. } else {
  346. this.is_agree = 0;
  347. }
  348. },
  349. },
  350. };
  351. </script>
  352. <style scoped lang="scss">
  353. @import "M_purchase.scss";
  354. .agree {
  355. width: 90%;
  356. margin: 0 auto;
  357. color: #666666;
  358. font-size: 24rpx;
  359. margin-top: 40rpx;
  360. display: flex;
  361. align-items: center;
  362. text-align: left;
  363. line-height: 32rpx;
  364. .agree2 {
  365. display: flex;
  366. flex-direction: row;
  367. justify-content: flex-start;
  368. align-items: center;
  369. padding-right: 8rpx;
  370. flex-shrink: 0;
  371. }
  372. .xy {
  373. color: #0084ff;
  374. display: inline;
  375. }
  376. image {
  377. width: 32rpx;
  378. height: 32rpx;
  379. }
  380. }
  381. .btn_submit {
  382. width: 626rpx;
  383. height: 88rpx;
  384. background: linear-gradient(90deg, #1f1f1f 0%, #444444 100%);
  385. border-radius: 76rpx;
  386. margin: 0 auto;
  387. margin-top: 70rpx;
  388. color: #acf934;
  389. display: flex;
  390. align-items: center;
  391. justify-content: center;
  392. font-size: 32rpx;
  393. line-height: 0;
  394. text {
  395. font-size: 44rpx;
  396. display: inline-block;
  397. margin-right: 10rpx;
  398. }
  399. }
  400. </style>