index.vue 17 KB

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