index.vue 18 KB

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