index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <template>
  2. <view>
  3. <view class="">
  4. <view class="margin-lr margin-top" style="position: relative;border-radius: 10upx;overflow: hidden;">
  5. <image src="https://mxys.chuanghai-tech.com/wmfile/20251112/c35cb76f45884a4a933c4a8d32c6742c.png" style="width: 100%;height: 250rpx;"></image>
  6. <view class=" u-flex u-p-l-30 u-p-t-40 u-p-b-30" style="position: absolute;top: 0;width: 100%;">
  7. <view class="u-m-r-20" style="margin-top: -15px;">
  8. <!-- <u-avatar :src="avatar" size="100"></u-avatar> -->
  9. <image src="https://mxys.chuanghai-tech.com/wmfile/20251112/34324c384d2543d0ba4cdfef27f6a337.png" style="width: 20px;height: 20px;"></image>
  10. </view>
  11. <view class="u-flex-1 ">
  12. <view class="" style="color: #2A748D; font-size: 20px;">{{userName}}</view>
  13. <view class="u-font-10 text-bold" style="margin-top: 10rpx;color: #376477;margin-left: -20px;" v-if="vipExpirationTime && isVip">有效期:{{vipExpirationTime}}</view>
  14. <view class="u-font-12 u-m-t-10 u-tips-color" style="color: #376477;margin-left: -20px;" v-if="!isVip">您目前还未开通会员
  15. </view>
  16. </view>
  17. </view>
  18. <image src="https://mxys.chuanghai-tech.com/wmfile/20251112/222489f5f1f24623b2dc8e93e836b5ca.png" style="width: 121px;height: 84px;float: right;margin-top: -120px;"></image>
  19. </view>
  20. <!-- <view class="flex justify-center margin-top-sm flex-wrap padding-lr-sm">
  21. <view style="display: inline-block;width: 216rpx;height: 250rpx;margin: 10rpx 10rpx;">
  22. <view class="text-center flex flex-direction justify-between padding-tb radius active"
  23. style="color: #DFC5A7;width: 216rpx;height: 250rpx;background: linear-gradient(-30deg, #2B2A30, #4A4A4A);border: 1px;">
  24. <view class="text-bold">月会员</view>
  25. <view class="text-bold">¥<text class="text-xxl">{{vipList.value}}</text></view>
  26. <view>立即购买</view>
  27. </view>
  28. </view>
  29. </view> -->
  30. <!-- <view class="flex justify-center align-center margin-top" v-if="!isVip">
  31. <view class="" @click="showpay=true"
  32. style="position: relative;left: 0;right: 0;border-radius: 10upx;overflow: hidden;display: inline-block;margin: auto;">
  33. <image src="../static/vip/bg.png" style="width: 459rpx;height: 129rpx;"></image>
  34. <view class="flex align-center"
  35. style="position: absolute;top: -10rpx;left:30rpx;bottom: 0;margin: auto; width: 100%;height: 100%;">
  36. <view class="text-bold">¥<text class="text-xxl">{{vipList.value}}</text></view>
  37. </view>
  38. </view>
  39. </view> -->
  40. <view class="padding-tb radius margin-top margin-lr vip2bg">
  41. <view class="text-center text-xl text-bold " style="color: #2A748D;">会员特权</view>
  42. <view class="flex flex-wrap">
  43. <view v-for="(item,index) in MemberList" :key="index"
  44. style="width: 33%;text-align: center;margin-top: 34upx;">
  45. <image :src="item.memberImg" mode="" style="margin: 0 auto;height: 45rpx;width: 45rpx;"></image>
  46. <view class="grid-text margin-top-sm" style="color: #2A748D;">{{item.memberName}}</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view style="width: 100%;height: 38rpx;"></view>
  51. <view class="nuanxin" @click="natNuan()">领取会员</view>
  52. <view style="margin-top: 38rpx;">
  53. <image style="width: 100%;height: 179px;" @click="clickImg" src="https://mxys.chuanghai-tech.com/wmfile/20251124/3247849b2d2849229013d9c41d0b5d93.png"></image>
  54. </view>
  55. </view>
  56. <view style="height: 110rpx;"></view>
  57. <view class="flex justify-between cu-bar foot bg padding-lr" v-if="!isVip">
  58. <view style="color: #DC2626;">
  59. <text style="color: #001713;">实付:</text><text style="font-size: 38upx;margin-top: 8upx;">¥{{price}}</text>
  60. </view>
  61. <view class="">
  62. <u-button :custom-style="customStyle" @click="popupShow2=true" shape="circle" :hair-line="false">立即开通
  63. </u-button>
  64. </view>
  65. </view>
  66. <!-- 支付方式 -->
  67. <u-popup v-model="showpay" mode="bottom" :closeable="closeable">
  68. <view class="popup_pay">
  69. <view style="background-color: #fff;">
  70. <view style="padding: 0 20upx;margin-top: 60rpx;margin-bottom: 20rpx;">
  71. <view
  72. style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
  73. v-for="(item,index) in openLists" :key='index'>
  74. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
  75. </image>
  76. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
  77. {{item.text}}
  78. </view>
  79. <radio-group name="openWay" style="margin-left: 45upx;" @tap='selectWay(item)'>
  80. <label class="tui-radio">
  81. <radio color="#1777FF" :checked="openWay === item.id ? true : false" />
  82. </label>
  83. </radio-group>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="pay_btn" @click="pay()">确认支付</view>
  88. </view>
  89. </u-popup>
  90. <!-- 推广码弹框 -->
  91. <u-popup v-model="popupShow2" border-radius="20" mode="center">
  92. <view class="nuan_kuang">
  93. <view style="text-align: center;font-size: 18px;color: #001713;">推广码</view>
  94. <view class="cu-form-group">
  95. <view class="title">推广码</view>
  96. <input placeholder="请输入推广码" style="border: 1rpx solid;padding-left: 10px;" name="input" v-model="tuiguangma"></input>
  97. </view>
  98. <view style="display: flex;margin-top: 20px;">
  99. <view class="nuan_butt" style="margin-left: 70px;" @click="tuiguang()">确定</view>
  100. </view>
  101. </view>
  102. </u-popup>
  103. <!-- 暖心认证弹框 -->
  104. <u-popup v-model="popupShow" border-radius="20" mode="center">
  105. <view class="nuan_kuang">
  106. <view style="text-align: center;font-size: 18px;color: #001713;">领取会员</view>
  107. <view class="cu-form-group">
  108. <view class="title">学号</view>
  109. <input placeholder="请输入学号" name="input" v-model="xuehao"></input>
  110. </view>
  111. <view class="cu-form-group">
  112. <view class="title">姓名</view>
  113. <input placeholder="请输入姓名" name="input" v-model="studentName" type="text"></input>
  114. </view>
  115. <view style="display: flex;margin-top: 20px;">
  116. <view class="nuan_qu" @click="popupShow=false">取消</view>
  117. <view class="nuan_butt" @click="nuanQue">确定</view>
  118. </view>
  119. </view>
  120. </u-popup>
  121. </view>
  122. </template>
  123. <script>
  124. export default {
  125. data() {
  126. return {
  127. vipExpirationTime:'',
  128. showpay: false,
  129. closeable: true,
  130. openLists: [],
  131. customStyle: {
  132. width: '136px',
  133. color: '#FFFFFF',
  134. background: "#2A748D",
  135. border: 0,
  136. fontWeight: '700'
  137. },
  138. gridData: [{
  139. title: '专享折上折',
  140. image: '../static/1.png'
  141. },
  142. {
  143. title: '特权礼物',
  144. image: '../static/2.png'
  145. },
  146. {
  147. title: '身份标识',
  148. image: '../static/3.png'
  149. },
  150. {
  151. title: '超值专享券',
  152. image: '../static/4.png'
  153. },
  154. {
  155. title: '商家特权',
  156. image: '../static/5.png'
  157. },
  158. {
  159. title: '定制挂件',
  160. image: '../static/6.png'
  161. }
  162. ],
  163. avatar: '',
  164. userName: '匿名',
  165. vipList: [],
  166. selNum: 1,
  167. newPrice: 0,
  168. money: 0,
  169. price: 0,
  170. MemberList: [],
  171. isVip: false,
  172. openWay: 2,
  173. popupShow:false,//暖心认证弹框
  174. tuiguangma:'',
  175. xuehao:'',
  176. studentName:'',
  177. popupShow2:false,//推广码弹框
  178. }
  179. },
  180. onLoad() {
  181. // #ifdef APP
  182. this.openLists = [{
  183. image: '../../static/images/my/weixin.png',
  184. text: '微信',
  185. id: 2
  186. }, {
  187. image: '../../static/images/my/zhifubao.png',
  188. text: '支付宝',
  189. id: 3
  190. },{
  191. image: '../../static/images/my/jinbi.png',
  192. text: '零钱',
  193. id: 1
  194. }]
  195. // #endif
  196. // #ifdef MP-WEIXIN
  197. this.openLists = [{
  198. image: '../../static/images/my/weixin.png',
  199. text: '微信',
  200. id: 2
  201. },
  202. // {
  203. // image: '../../static/images/my/jinbi.png',
  204. // text: '零钱',
  205. // id: 1
  206. // },
  207. ]
  208. // #endif
  209. // #ifdef H5
  210. this.openLists = [{
  211. image: '../../static/images/my/weixin.png',
  212. text: '微信',
  213. id: 2
  214. },{
  215. image: '../../static/images/my/zhifubao.png',
  216. text: '支付宝',
  217. id: 3
  218. },{
  219. image: '../../static/images/my/jinbi.png',
  220. text: '零钱',
  221. id: 1
  222. }]
  223. // #endif
  224. this.avatar = uni.getStorageSync('avatar')
  225. this.userName = uni.getStorageSync('userName')
  226. this.getVipList()
  227. this.getMemberList()
  228. this.getMoney()
  229. this.getIsVip()
  230. this.getUserInfo()
  231. },
  232. methods: {
  233. //点击放大图片
  234. clickImg(){
  235. wx.previewImage({
  236. urls: [], //需要预览的图片http链接列表,多张的时候,url直接写在后面就行了
  237. current:'https://mxys.chuanghai-tech.com/wmfile/20251124/3247849b2d2849229013d9c41d0b5d93.png', // 当前显示图片的http链接,默认是第一个
  238. success: function(res) {},
  239. fail: function(res) {},
  240. complete: function(res) {},
  241. })
  242. },
  243. //推广码弹框
  244. tuiguang(){
  245. if (!this.tuiguangma) {
  246. this.$queue.showToast("请输入推广码");
  247. }else{
  248. this.popupShow2=false
  249. this.showpay=true
  250. }
  251. },
  252. //暖心认证
  253. natNuan(){
  254. if(this.isVip==true){
  255. this.$queue.showToast("已是会员,请勿重复操作");
  256. }else{
  257. this.popupShow=true
  258. }
  259. },
  260. //提交认证
  261. nuanQue() {
  262. const data={
  263. "name": this.studentName,
  264. "studentNumber": this.xuehao,
  265. }
  266. console.log('提交1',data)
  267. if (!this.studentName) {
  268. this.$queue.showToast("请输入姓名");
  269. } else if (!this.xuehao) {
  270. this.$queue.showToast("请输入学号");
  271. }else {
  272. this.$queue.showLoading("加载中...");
  273. this.$Request.postJson("/app/special-favor-student/verify", {
  274. name: this.studentName,
  275. studentNumber: this.xuehao,
  276. }).then(res => {
  277. console.log('提交',res)
  278. if (res.code == 0) {
  279. uni.hideLoading()
  280. setTimeout(function() {
  281. this.popupShow=false
  282. this.getIsVip()
  283. }, 10)
  284. } else {
  285. uni.hideLoading();
  286. this.$queue.showToast(res.msg);
  287. }
  288. });
  289. }
  290. },
  291. selectWay: function(item) {
  292. this.openWay = item.id;
  293. },
  294. getUserInfo() {
  295. this.$Request.get("/app/user/selectUserById").then(res => {
  296. if (res.code == 0) {
  297. this.avatar = res.data.avatar ? res.data.avatar : 'https://mxys.chuanghai-tech.com/wmfile/20250814/fff4dc5d02ea4af881db9685f2e1e61d.png'
  298. uni.setStorageSync('avatar', res.data.avatar)
  299. }
  300. });
  301. },
  302. //获取VIP列表
  303. getVipList() {
  304. this.$Request.get('/app/common/type/313').then(res => {
  305. if (res.code == 0) {
  306. this.vipList = res.data
  307. this.price = this.vipList.value
  308. }
  309. })
  310. },
  311. // 获取特权列表
  312. getMemberList() {
  313. this.$Request.get('/app/member/selectMemberList').then(res => {
  314. console.log(res,'会员特权')
  315. if (res.code == 0) {
  316. this.MemberList = res.data
  317. }
  318. })
  319. },
  320. getIsVip() {
  321. this.$Request.get("/app/user/selectUserMessage").then(res => {
  322. console.log(res,'会员')
  323. if (res.code == 0) {
  324. this.vipExpirationTime = res.data.vipExpirationTime;
  325. this.isVip = res.data.isVip==1?true:false
  326. }
  327. });
  328. },
  329. // 我的金币
  330. getMoney() {
  331. this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
  332. if (res.code == 0 && res.data) {
  333. this.money = res.data.money
  334. }
  335. });
  336. },
  337. select(e) {
  338. this.selNum = e.id
  339. this.price = e.money
  340. },
  341. pay() {
  342. let userId = uni.getStorageSync('userId')
  343. this.showpay = false
  344. if (this.openWay == 1) { //余额支付/app/wxPay/balanceBuyVip
  345. let data1 = {
  346. // type: 3,
  347. userId:userId,
  348. promoCode:this.tuiguangma,
  349. }
  350. this.$Request.get("/app/vip/balance-pay", data1).then(res => {
  351. if (res.code == 0) {
  352. this.$queue.showToast('支付成功');
  353. setTimeout(function() {
  354. uni.navigateBack()
  355. }, 1000)
  356. }else {
  357. this.$queue.showToast(res.msg);
  358. }
  359. });
  360. } else if (this.openWay == 2) { //微信支付
  361. // #ifdef MP-WEIXIN
  362. let data = {
  363. // type: 3,
  364. userId:userId,
  365. promoCode:this.tuiguangma,
  366. }///app/wxPay/wxPayJsApiBuyVip
  367. console.log(data,'支付')
  368. this.$Request.get('/app/vip/get-pay-param', data).then(res => {
  369. console.log(res)
  370. if (res.code == 0) {
  371. uni.requestPayment({
  372. provider: 'wxpay',
  373. timeStamp: res.timeStamp,
  374. nonceStr: res.nonceStr,
  375. package: res.packageStr,
  376. signType: res.signType,
  377. paySign: res.paySign,
  378. success: function(res) {
  379. console.log(res)
  380. uni.showLoading({
  381. title: '支付成功',
  382. icon: 'none'
  383. });
  384. setTimeout(function() {
  385. uni.navigateBack()
  386. }, 1000)
  387. },
  388. fail: function(err) {
  389. uni.showLoading({
  390. title: '支付失败',
  391. icon: 'nones'
  392. });
  393. }
  394. });
  395. }
  396. });
  397. // #endif
  398. // #ifdef H5
  399. let data = {
  400. userId: userId,
  401. type: 2
  402. }
  403. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  404. this.showpay = false
  405. this.callPay(res);
  406. });
  407. // #endif
  408. // #ifdef APP
  409. let data = {
  410. type: 1
  411. }
  412. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  413. console.log(res)
  414. this.showpay = false
  415. if (res.code == 0) {
  416. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  417. }
  418. });
  419. // #endif
  420. } else if (this.openWay == 3) { //支付宝支付
  421. // #ifdef H5
  422. let data = {
  423. type: 5
  424. }
  425. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(
  426. res => {
  427. this.showpay = false
  428. const div = document.createElement('div')
  429. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  430. document.body.appendChild(div)
  431. document.forms[0].submit()
  432. });
  433. // #endif
  434. // #ifdef APP-PLUS
  435. let data = {
  436. type: 4
  437. }
  438. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  439. this.showpay = false
  440. this.setPayment('alipay', res.data);
  441. });
  442. // #endif
  443. }
  444. },
  445. callPay: function(response) {
  446. if (typeof WeixinJSBridge === "undefined") {
  447. if (document.addEventListener) {
  448. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  449. } else if (document.attachEvent) {
  450. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  451. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  452. }
  453. } else {
  454. this.onBridgeReady(response);
  455. }
  456. },
  457. onBridgeReady: function(response) {
  458. let that = this;
  459. console.log(response)
  460. if (!response.package) {
  461. return;
  462. }
  463. WeixinJSBridge.invoke(
  464. 'getBrandWCPayRequest', {
  465. "appId": response.appid, //公众号名称,由商户传入
  466. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  467. "nonceStr": response.noncestr, //随机串
  468. "package": response.package,
  469. "signType": response.signType, //微信签名方式:
  470. "paySign": response.sign //微信签名
  471. },
  472. function(res) {
  473. if (res.err_msg === "get_brand_wcpay_request:ok") {
  474. // 使用以上方式判断前端返回,微信团队郑重提示:
  475. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  476. uni.showLoading({
  477. title: '支付成功'
  478. });
  479. uni.hideLoading();
  480. uni.navigateTo({
  481. url: '/pages/my/index'
  482. })
  483. } else {
  484. uni.hideLoading();
  485. }
  486. WeixinJSBridge.log(response.err_msg);
  487. }
  488. );
  489. },
  490. isCheckPay(code, name, order) {
  491. if (code == 0) {
  492. console.log('999999999999')
  493. this.setPayment(name, order);
  494. } else {
  495. uni.hideLoading();
  496. uni.showToast({
  497. title: '支付信息有误'
  498. });
  499. }
  500. },
  501. setPayment(name, order) {
  502. console.log(777777777, name, order)
  503. uni.requestPayment({
  504. provider: name,
  505. orderInfo: order, //微信、支付宝订单数据
  506. success: function(res) {
  507. uni.hideLoading();
  508. uni.showLoading({
  509. title: '支付成功',
  510. icon: 'none'
  511. });
  512. setTimeout(function() {
  513. uni.navigateBack()
  514. }, 1000)
  515. },
  516. fail: function(err) {
  517. uni.hideLoading();
  518. },
  519. complete() {
  520. uni.hideLoading();
  521. }
  522. });
  523. }
  524. },
  525. computed: {
  526. }
  527. }
  528. </script>
  529. <style>
  530. .bg {
  531. background-color: #FFFFFF;
  532. }
  533. .btn {
  534. width: 100%;
  535. height: 88upx;
  536. background: linear-gradient(0deg, #af8262 0%, #cab49c 100%);
  537. border-radius: 44upx;
  538. text-align: center;
  539. line-height: 88upx;
  540. margin-top: 40upx;
  541. font-size: 34upx;
  542. font-weight: 600;
  543. color: #402321;
  544. }
  545. .active {
  546. border: 1px solid #cab49c !important;
  547. border-radius: ;
  548. }
  549. .popup_pay {
  550. width: 100%;
  551. position: relative;
  552. padding-bottom: 45rpx;
  553. }
  554. .pay_btn {
  555. width: 90%;
  556. margin: 0 auto;
  557. text-align: center;
  558. background: #FCD202;
  559. height: 80rpx;
  560. border-radius: 16rpx;
  561. color: #ffffff;
  562. line-height: 80rpx;
  563. }
  564. .vip2bg{
  565. background-image: url('https://mxys.chuanghai-tech.com/wmfile/20251112/16095cb872cf4572afc82f8755d74951.png');
  566. background-size: 100%;
  567. }
  568. /* 暖心认证 */
  569. .nuanxin{
  570. position: relative;
  571. width: 177px;
  572. height: 47px;
  573. background-color: #2A748D;
  574. color: #ffffff;
  575. font-size: 18px;
  576. border-radius: 32px;
  577. text-align: center;
  578. line-height: 47px;
  579. margin: auto;
  580. }
  581. /* 暖心认证弹框 */
  582. .nuan_kuang{
  583. padding: 30rpx 30rpx 30rpx 30rpx;
  584. font-size: 15px;
  585. width: 300px;
  586. height: 180px;
  587. }
  588. .nuan_qu{
  589. width: 130px;
  590. height: 33px;
  591. border: 2rpx solid rgba(129, 189, 179, 1);
  592. background-color: rgba(129, 189, 179, 0.4);
  593. color: #001713;
  594. font-size: 14px;
  595. border-radius: 16px;
  596. text-align: center;
  597. line-height: 33px;
  598. }
  599. .nuan_butt{
  600. margin-left: 20px;
  601. width: 130px;
  602. height: 33px;
  603. background-color: #2A748D;
  604. color: #ffffff;
  605. font-size: 14px;
  606. border-radius: 16px;
  607. text-align: center;
  608. line-height: 33px;
  609. }
  610. </style>