index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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 class="padding-lr" style="margin-top: 38rpx;">
  53. <image style="width: 100%;height: 139px;" @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" maxlength="11"></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" maxlength="11"></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. this.popupShow=true
  255. },
  256. //提交认证
  257. nuanQue() {
  258. const data={
  259. "name": this.studentName,
  260. "studentNumber": this.xuehao,
  261. }
  262. console.log('提交1',data)
  263. if (!this.studentName) {
  264. this.$queue.showToast("请输入姓名");
  265. } else if (!this.xuehao) {
  266. this.$queue.showToast("请输入学号");
  267. }else {
  268. this.$queue.showLoading("加载中...");
  269. this.$Request.postJson("/app/special-favor-student/verify", {
  270. name: this.studentName,
  271. studentNumber: this.xuehao,
  272. }).then(res => {
  273. console.log('提交',res)
  274. if (res.code == 0) {
  275. uni.hideLoading()
  276. setTimeout(function() {
  277. this.popupShow=false
  278. this.getIsVip()
  279. }, 10)
  280. } else {
  281. uni.hideLoading();
  282. this.$queue.showToast(res.msg);
  283. }
  284. });
  285. }
  286. },
  287. selectWay: function(item) {
  288. this.openWay = item.id;
  289. },
  290. getUserInfo() {
  291. this.$Request.get("/app/user/selectUserById").then(res => {
  292. if (res.code == 0) {
  293. this.avatar = res.data.avatar ? res.data.avatar : 'https://mxys.chuanghai-tech.com/wmfile/20250814/fff4dc5d02ea4af881db9685f2e1e61d.png'
  294. uni.setStorageSync('avatar', res.data.avatar)
  295. }
  296. });
  297. },
  298. //获取VIP列表
  299. getVipList() {
  300. this.$Request.get('/app/common/type/313').then(res => {
  301. if (res.code == 0) {
  302. this.vipList = res.data
  303. this.price = this.vipList.value
  304. }
  305. })
  306. },
  307. // 获取特权列表
  308. getMemberList() {
  309. this.$Request.get('/app/member/selectMemberList').then(res => {
  310. console.log(res,'会员特权')
  311. if (res.code == 0) {
  312. this.MemberList = res.data
  313. }
  314. })
  315. },
  316. getIsVip() {
  317. this.$Request.get("/app/user/selectUserMessage").then(res => {
  318. console.log(res,'会员')
  319. if (res.code == 0) {
  320. this.vipExpirationTime = res.data.vipExpirationTime;
  321. this.isVip = res.data.isVip==1?true:false
  322. }
  323. });
  324. },
  325. // 我的金币
  326. getMoney() {
  327. this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
  328. if (res.code == 0 && res.data) {
  329. this.money = res.data.money
  330. }
  331. });
  332. },
  333. select(e) {
  334. this.selNum = e.id
  335. this.price = e.money
  336. },
  337. pay() {
  338. let userId = uni.getStorageSync('userId')
  339. this.showpay = false
  340. if (this.openWay == 1) { //余额支付/app/wxPay/balanceBuyVip
  341. let data1 = {
  342. // type: 3,
  343. userId:userId,
  344. promoCode:this.tuiguangma,
  345. }
  346. this.$Request.get("/app/vip/balance-pay", data1).then(res => {
  347. if (res.code == 0) {
  348. this.$queue.showToast('支付成功');
  349. setTimeout(function() {
  350. uni.navigateBack()
  351. }, 1000)
  352. }else {
  353. this.$queue.showToast(res.msg);
  354. }
  355. });
  356. } else if (this.openWay == 2) { //微信支付
  357. // #ifdef MP-WEIXIN
  358. let data = {
  359. // type: 3,
  360. userId:userId,
  361. promoCode:this.tuiguangma,
  362. }///app/wxPay/wxPayJsApiBuyVip
  363. console.log(data,'支付')
  364. this.$Request.get('/app/vip/get-pay-param', data).then(res => {
  365. console.log(res)
  366. if (res.code == 0) {
  367. uni.requestPayment({
  368. provider: 'wxpay',
  369. timeStamp: res.timeStamp,
  370. nonceStr: res.nonceStr,
  371. package: res.packageStr,
  372. signType: res.signType,
  373. paySign: res.paySign,
  374. success: function(res) {
  375. console.log(res)
  376. uni.showLoading({
  377. title: '支付成功',
  378. icon: 'none'
  379. });
  380. setTimeout(function() {
  381. uni.navigateBack()
  382. }, 1000)
  383. },
  384. fail: function(err) {
  385. uni.showLoading({
  386. title: '支付失败',
  387. icon: 'nones'
  388. });
  389. }
  390. });
  391. }
  392. });
  393. // #endif
  394. // #ifdef H5
  395. let data = {
  396. userId: userId,
  397. type: 2
  398. }
  399. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  400. this.showpay = false
  401. this.callPay(res);
  402. });
  403. // #endif
  404. // #ifdef APP
  405. let data = {
  406. type: 1
  407. }
  408. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  409. console.log(res)
  410. this.showpay = false
  411. if (res.code == 0) {
  412. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  413. }
  414. });
  415. // #endif
  416. } else if (this.openWay == 3) { //支付宝支付
  417. // #ifdef H5
  418. let data = {
  419. type: 5
  420. }
  421. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(
  422. res => {
  423. this.showpay = false
  424. const div = document.createElement('div')
  425. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  426. document.body.appendChild(div)
  427. document.forms[0].submit()
  428. });
  429. // #endif
  430. // #ifdef APP-PLUS
  431. let data = {
  432. type: 4
  433. }
  434. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  435. this.showpay = false
  436. this.setPayment('alipay', res.data);
  437. });
  438. // #endif
  439. }
  440. },
  441. callPay: function(response) {
  442. if (typeof WeixinJSBridge === "undefined") {
  443. if (document.addEventListener) {
  444. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  445. } else if (document.attachEvent) {
  446. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  447. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  448. }
  449. } else {
  450. this.onBridgeReady(response);
  451. }
  452. },
  453. onBridgeReady: function(response) {
  454. let that = this;
  455. console.log(response)
  456. if (!response.package) {
  457. return;
  458. }
  459. WeixinJSBridge.invoke(
  460. 'getBrandWCPayRequest', {
  461. "appId": response.appid, //公众号名称,由商户传入
  462. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  463. "nonceStr": response.noncestr, //随机串
  464. "package": response.package,
  465. "signType": response.signType, //微信签名方式:
  466. "paySign": response.sign //微信签名
  467. },
  468. function(res) {
  469. if (res.err_msg === "get_brand_wcpay_request:ok") {
  470. // 使用以上方式判断前端返回,微信团队郑重提示:
  471. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  472. uni.showLoading({
  473. title: '支付成功'
  474. });
  475. uni.hideLoading();
  476. uni.navigateTo({
  477. url: '/pages/my/index'
  478. })
  479. } else {
  480. uni.hideLoading();
  481. }
  482. WeixinJSBridge.log(response.err_msg);
  483. }
  484. );
  485. },
  486. isCheckPay(code, name, order) {
  487. if (code == 0) {
  488. console.log('999999999999')
  489. this.setPayment(name, order);
  490. } else {
  491. uni.hideLoading();
  492. uni.showToast({
  493. title: '支付信息有误'
  494. });
  495. }
  496. },
  497. setPayment(name, order) {
  498. console.log(777777777, name, order)
  499. uni.requestPayment({
  500. provider: name,
  501. orderInfo: order, //微信、支付宝订单数据
  502. success: function(res) {
  503. uni.hideLoading();
  504. uni.showLoading({
  505. title: '支付成功',
  506. icon: 'none'
  507. });
  508. setTimeout(function() {
  509. uni.navigateBack()
  510. }, 1000)
  511. },
  512. fail: function(err) {
  513. uni.hideLoading();
  514. },
  515. complete() {
  516. uni.hideLoading();
  517. }
  518. });
  519. }
  520. },
  521. computed: {
  522. }
  523. }
  524. </script>
  525. <style>
  526. .bg {
  527. background-color: #FFFFFF;
  528. }
  529. .btn {
  530. width: 100%;
  531. height: 88upx;
  532. background: linear-gradient(0deg, #af8262 0%, #cab49c 100%);
  533. border-radius: 44upx;
  534. text-align: center;
  535. line-height: 88upx;
  536. margin-top: 40upx;
  537. font-size: 34upx;
  538. font-weight: 600;
  539. color: #402321;
  540. }
  541. .active {
  542. border: 1px solid #cab49c !important;
  543. border-radius: ;
  544. }
  545. .popup_pay {
  546. width: 100%;
  547. position: relative;
  548. padding-bottom: 45rpx;
  549. }
  550. .pay_btn {
  551. width: 90%;
  552. margin: 0 auto;
  553. text-align: center;
  554. background: #FCD202;
  555. height: 80rpx;
  556. border-radius: 16rpx;
  557. color: #ffffff;
  558. line-height: 80rpx;
  559. }
  560. .vip2bg{
  561. background-image: url('https://mxys.chuanghai-tech.com/wmfile/20251112/16095cb872cf4572afc82f8755d74951.png');
  562. background-size: 100%;
  563. }
  564. /* 暖心认证 */
  565. .nuanxin{
  566. width: 177px;
  567. height: 47px;
  568. background-color: #2A748D;
  569. color: #ffffff;
  570. font-size: 18px;
  571. border-radius: 32px;
  572. text-align: center;
  573. line-height: 47px;
  574. margin: auto;
  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>