index.vue 18 KB

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