index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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()">领取会员</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. this.isVip = res.data.isVip==1?true:false
  327. }
  328. });
  329. },
  330. // 我的金币
  331. getMoney() {
  332. this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
  333. if (res.code == 0 && res.data) {
  334. this.money = res.data.money
  335. }
  336. });
  337. },
  338. select(e) {
  339. this.selNum = e.id
  340. this.price = e.money
  341. },
  342. pay() {
  343. let userId = uni.getStorageSync('userId')
  344. this.showpay = false
  345. if (this.openWay == 1) { //余额支付/app/wxPay/balanceBuyVip
  346. let data1 = {
  347. // type: 3,
  348. userId:userId,
  349. promoCode:this.tuiguangma,
  350. }
  351. this.$Request.get("/app/vip/balance-pay", data1).then(res => {
  352. if (res.code == 0) {
  353. this.$queue.showToast('支付成功');
  354. setTimeout(function() {
  355. uni.navigateBack()
  356. }, 1000)
  357. }else {
  358. this.$queue.showToast(res.msg);
  359. }
  360. });
  361. } else if (this.openWay == 2) { //微信支付
  362. // #ifdef MP-WEIXIN
  363. let data = {
  364. // type: 3,
  365. userId:userId,
  366. promoCode:this.tuiguangma,
  367. }///app/wxPay/wxPayJsApiBuyVip
  368. console.log(data,'支付')
  369. this.$Request.get('/app/vip/get-pay-param', data).then(res => {
  370. console.log(res)
  371. if (res.code == 0) {
  372. uni.requestPayment({
  373. provider: 'wxpay',
  374. timeStamp: res.timeStamp,
  375. nonceStr: res.nonceStr,
  376. package: res.packageStr,
  377. signType: res.signType,
  378. paySign: res.paySign,
  379. success: function(res) {
  380. console.log(res)
  381. uni.showLoading({
  382. title: '支付成功',
  383. icon: 'none'
  384. });
  385. setTimeout(function() {
  386. uni.navigateBack()
  387. }, 1000)
  388. },
  389. fail: function(err) {
  390. uni.showLoading({
  391. title: '支付失败',
  392. icon: 'nones'
  393. });
  394. }
  395. });
  396. }
  397. });
  398. // #endif
  399. // #ifdef H5
  400. let data = {
  401. userId: userId,
  402. type: 2
  403. }
  404. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  405. this.showpay = false
  406. this.callPay(res);
  407. });
  408. // #endif
  409. // #ifdef APP
  410. let data = {
  411. type: 1
  412. }
  413. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  414. console.log(res)
  415. this.showpay = false
  416. if (res.code == 0) {
  417. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  418. }
  419. });
  420. // #endif
  421. } else if (this.openWay == 3) { //支付宝支付
  422. // #ifdef H5
  423. let data = {
  424. type: 5
  425. }
  426. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(
  427. res => {
  428. this.showpay = false
  429. const div = document.createElement('div')
  430. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  431. document.body.appendChild(div)
  432. document.forms[0].submit()
  433. });
  434. // #endif
  435. // #ifdef APP-PLUS
  436. let data = {
  437. type: 4
  438. }
  439. this.$Request.post('/app/wxPay/wxPayJsApiBuyVip', data).then(res => {
  440. this.showpay = false
  441. this.setPayment('alipay', res.data);
  442. });
  443. // #endif
  444. }
  445. },
  446. callPay: function(response) {
  447. if (typeof WeixinJSBridge === "undefined") {
  448. if (document.addEventListener) {
  449. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  450. } else if (document.attachEvent) {
  451. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  452. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  453. }
  454. } else {
  455. this.onBridgeReady(response);
  456. }
  457. },
  458. onBridgeReady: function(response) {
  459. let that = this;
  460. console.log(response)
  461. if (!response.package) {
  462. return;
  463. }
  464. WeixinJSBridge.invoke(
  465. 'getBrandWCPayRequest', {
  466. "appId": response.appid, //公众号名称,由商户传入
  467. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  468. "nonceStr": response.noncestr, //随机串
  469. "package": response.package,
  470. "signType": response.signType, //微信签名方式:
  471. "paySign": response.sign //微信签名
  472. },
  473. function(res) {
  474. if (res.err_msg === "get_brand_wcpay_request:ok") {
  475. // 使用以上方式判断前端返回,微信团队郑重提示:
  476. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  477. uni.showLoading({
  478. title: '支付成功'
  479. });
  480. uni.hideLoading();
  481. uni.navigateTo({
  482. url: '/pages/my/index'
  483. })
  484. } else {
  485. uni.hideLoading();
  486. }
  487. WeixinJSBridge.log(response.err_msg);
  488. }
  489. );
  490. },
  491. isCheckPay(code, name, order) {
  492. if (code == 0) {
  493. console.log('999999999999')
  494. this.setPayment(name, order);
  495. } else {
  496. uni.hideLoading();
  497. uni.showToast({
  498. title: '支付信息有误'
  499. });
  500. }
  501. },
  502. setPayment(name, order) {
  503. console.log(777777777, name, order)
  504. uni.requestPayment({
  505. provider: name,
  506. orderInfo: order, //微信、支付宝订单数据
  507. success: function(res) {
  508. uni.hideLoading();
  509. uni.showLoading({
  510. title: '支付成功',
  511. icon: 'none'
  512. });
  513. setTimeout(function() {
  514. uni.navigateBack()
  515. }, 1000)
  516. },
  517. fail: function(err) {
  518. uni.hideLoading();
  519. },
  520. complete() {
  521. uni.hideLoading();
  522. }
  523. });
  524. }
  525. },
  526. computed: {
  527. }
  528. }
  529. </script>
  530. <style>
  531. .bg {
  532. background-color: #FFFFFF;
  533. }
  534. .btn {
  535. width: 100%;
  536. height: 88upx;
  537. background: linear-gradient(0deg, #af8262 0%, #cab49c 100%);
  538. border-radius: 44upx;
  539. text-align: center;
  540. line-height: 88upx;
  541. margin-top: 40upx;
  542. font-size: 34upx;
  543. font-weight: 600;
  544. color: #402321;
  545. }
  546. .active {
  547. border: 1px solid #cab49c !important;
  548. border-radius: ;
  549. }
  550. .popup_pay {
  551. width: 100%;
  552. position: relative;
  553. padding-bottom: 45rpx;
  554. }
  555. .pay_btn {
  556. width: 90%;
  557. margin: 0 auto;
  558. text-align: center;
  559. background: #FCD202;
  560. height: 80rpx;
  561. border-radius: 16rpx;
  562. color: #ffffff;
  563. line-height: 80rpx;
  564. }
  565. .vip2bg{
  566. background-image: url('https://mxys.chuanghai-tech.com/wmfile/20251112/16095cb872cf4572afc82f8755d74951.png');
  567. background-size: 100%;
  568. }
  569. /* 暖心认证 */
  570. .nuanxin{
  571. position: relative;
  572. width: 177px;
  573. height: 47px;
  574. background-color: #2A748D;
  575. color: #ffffff;
  576. font-size: 18px;
  577. border-radius: 32px;
  578. text-align: center;
  579. line-height: 47px;
  580. margin: auto;
  581. }
  582. /* 暖心认证弹框 */
  583. .nuan_kuang{
  584. padding: 30rpx 30rpx 30rpx 30rpx;
  585. font-size: 15px;
  586. width: 300px;
  587. height: 180px;
  588. }
  589. .nuan_qu{
  590. width: 130px;
  591. height: 33px;
  592. border: 2rpx solid rgba(129, 189, 179, 1);
  593. background-color: rgba(129, 189, 179, 0.4);
  594. color: #001713;
  595. font-size: 14px;
  596. border-radius: 16px;
  597. text-align: center;
  598. line-height: 33px;
  599. }
  600. .nuan_butt{
  601. margin-left: 20px;
  602. width: 130px;
  603. height: 33px;
  604. background-color: #2A748D;
  605. color: #ffffff;
  606. font-size: 14px;
  607. border-radius: 16px;
  608. text-align: center;
  609. line-height: 33px;
  610. }
  611. </style>