index.vue 19 KB

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