activity.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <template>
  2. <view class="container_box">
  3. <view class="header-nav"
  4. :style="{height: `calc(88rpx + ${statusBarHeight}px)`,paddingTop: statusBarHeight + 'px'}">
  5. </view>
  6. <view class="conbox">
  7. <image class="activity_yh_right" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_yh_right.png"
  8. mode="widthFix"></image>
  9. <image class="activity_yh_left" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_yh_left.png"
  10. mode="widthFix"></image>
  11. <image class="activity_title" v-if="collectType!=2&&isExpiry"
  12. src="https://cdn.his.cdwjyyh.com/minapp/course/activity_title.png" mode="widthFix"></image>
  13. <view class="activity_title2" v-if="!isExpiry==1&&collectType==2">
  14. 福袋已经失效了~
  15. </view>
  16. <template v-if="collectType==1">
  17. <view class="activity_title3">
  18. 您已经领取过本次福袋啦~
  19. </view>
  20. <view class="activity_title4">
  21. 赶紧前往芳华未来APP,兑换好物吧
  22. </view>
  23. </template>
  24. <view class="ybg_box">
  25. <view class="ybg"></view>
  26. <image class="activity_lucky_bag" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_lucky_bag.png"
  27. mode="heightFix"></image>
  28. <image class="activity_ysx" v-show="!isExpiry==1&&collectType==2"
  29. src="https://cdn.his.cdwjyyh.com/minapp/course/activity_ysx.png" mode="widthFix"></image>
  30. <image class="activity_ylq" v-show="collectType==1"
  31. src="https://cdn.his.cdwjyyh.com/minapp/course/activity_ylq.png" mode="widthFix"></image>
  32. </view>
  33. <view class="activity_btn animation" v-if="collectType!=2&&isExpiry" @click="handleReceive">
  34. <view class="btn">领取福袋</view>
  35. <image src="https://cdn.his.cdwjyyh.com/minapp/course/activity_btn.png" mode="heightFix"></image>
  36. <view class="exsct"></view>
  37. </view>
  38. <view class="activity_btn_down x-c" v-else @click="navTo">
  39. <text>如何下载芳华未来APP</text>
  40. <image src="https://cdn.his.cdwjyyh.com/minapp/course/activity_more.png" mode="aspectFill"></image>
  41. </view>
  42. </view>
  43. <image class="footer_img" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_xy.png" mode="widthFix">
  44. </image>
  45. <u-popup :show="show" mode="center" bgColor="transparent" :closeOnClickOverlay="false" overlayOpacity="0.7">
  46. <view class="popup-box">
  47. <image class="activity_jb" src="https://cdn.his.cdwjyyh.com/minapp/course/activity_jb.png"
  48. mode="heightFix"></image>
  49. <text class="popup-tit">恭喜您获得</text>
  50. <view class="con">
  51. <view class="numbox color_FB2205"><text class="num">+{{coinAmount||0}}</text>芳华币</view>
  52. <view>您的芳华币总额:<text class="color_FB2205" style="font-weight: 600;">{{balance||0}}</text></view>
  53. </view>
  54. <view class="popup-tips">赶紧去芳华未来APP,兑换好物吧~</view>
  55. <view class="popbtn x-c" @click="show=false">我知道啦</view>
  56. </view>
  57. <view class="popup-tips" style="color: #FFFFFF;margin-top: 60rpx;">兑换提示:请前往芳华未来APP兑换</view>
  58. <view class="popup-tips" style="color: #FFC05C;text-decoration-line: underline;" @click="navTo">如何下载芳华未来APP?
  59. </view>
  60. </u-popup>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. mapGetters
  66. } from 'vuex';
  67. import {
  68. getLuckyBagInfo,
  69. receiveLuckyBag
  70. } from '@/api/course.js'
  71. export default {
  72. data() {
  73. return {
  74. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  75. show: false,
  76. status: 0,
  77. recordId: '',
  78. urlOption: {},
  79. sortLink: '',
  80. corpId: null,
  81. isLogin: false,
  82. isLoginH5: 0, // 1服务号授权
  83. collectType: -1, // 领取状态(0-已发放 1-已领取 2-已失效)
  84. isExpiry: true, // false 失效 true 有效
  85. coinAmount: 0,
  86. balance: 0
  87. }
  88. },
  89. computed: {
  90. ...mapGetters(['coureLogin']),
  91. },
  92. watch: {
  93. coureLogin: {
  94. immediate: true, // 页面一进入就检查一次
  95. handler(val) {
  96. if (val == 2 && this.isLogin) {
  97. console.log("注册AppToken失效,请重新登录")
  98. uni.removeStorageSync('web_userInfo');
  99. uni.removeStorageSync('TOKEN_WEXIN');
  100. this.isLogin = false
  101. if (this.isLoginH5 == 0) {
  102. this.goWXLogin()
  103. } else {
  104. this.goLogin()
  105. }
  106. }
  107. }
  108. }
  109. },
  110. onLoad(option) {
  111. this.recordId = option.recordId || ''
  112. this.urlOption = option.link ? JSON.parse(decodeURIComponent(option.link)) : {},
  113. this.sortLink = this.urlOption.link || ''
  114. this.corpId = this.urlOption.corpId
  115. console.log(this.sortLink)
  116. },
  117. methods: {
  118. goBack() {
  119. uni.navigateBack();
  120. },
  121. handleReceive() {
  122. if (this.isLoginH5 == 0) {
  123. this.utils.isLoginCourse().then(
  124. isLogin => {
  125. this.isLogin = isLogin
  126. if (this.isLogin) {
  127. // this.editUserA()
  128. if (this.chatId != '' || this.chatId) {
  129. this.userlogo = true
  130. } else {
  131. this.receiveLuckyBag(1)
  132. }
  133. } else {
  134. this.goLogin()
  135. }
  136. },
  137. rej => {}
  138. );
  139. } else {
  140. this.utils.isLoginResCourse().then(
  141. isLogin => {
  142. this.isLogin = isLogin
  143. if (this.isLogin) {
  144. this.receiveLuckyBag(1)
  145. } else {
  146. this.goLogin()
  147. }
  148. },
  149. rej => {}
  150. );
  151. }
  152. this.show = true
  153. },
  154. receiveLuckyBag(type) {
  155. uni.showToast({
  156. title: '领取中...',
  157. icon: 'loading'
  158. });
  159. receiveLuckyBag({...this.urlOption}).then(res => {
  160. uni.hideLoading()
  161. if(res.code == 200) {
  162. this.coinAmount = 0
  163. this.balance = 0
  164. this.show = true
  165. } else {
  166. uni.showModal({
  167. title: '领取失败',
  168. content: res.msg,
  169. showCancel: false,
  170. success: function (res) {
  171. if (res.confirm) {
  172. console.log('用户点击确定');
  173. } else if (res.cancel) {
  174. console.log('用户点击取消');
  175. }
  176. }
  177. });
  178. }
  179. })
  180. },
  181. navTo() {
  182. this.show = false
  183. uni.navigateTo({
  184. url: '/pages_course/appDownload'
  185. })
  186. },
  187. getLuckyBagInfo() {
  188. getLuckyBagInfo({
  189. recordId: this.recordId
  190. }).then(res => {
  191. if (res.code == 200) {
  192. this.collectType = res.data.collectType; //领取状态(0-已发放 1-已领取 2-已失效)
  193. this.isExpiry = res.data.isExpiry; //false 失效 true 有效
  194. } else {
  195. uni.showToast({
  196. title: res.msg,
  197. icon: 'none'
  198. });
  199. }
  200. })
  201. },
  202. goLogin(data) {
  203. if (this.isLoginH5 == 0) {
  204. this.goWXLogin()
  205. return
  206. }
  207. },
  208. goWXLogin() {
  209. this.utils.getProvider().then(provider => {
  210. console.log('当前的环境商', provider)
  211. if (!provider) {
  212. reject()
  213. }
  214. uni.login({
  215. provider: provider,
  216. success: async loginRes => {
  217. console.log(loginRes)
  218. uni.getUserInfo({
  219. provider: provider,
  220. success: (infoRes) => {
  221. uni.showToast({
  222. title: '登录中...',
  223. icon: 'loading'
  224. });
  225. loginByMp({
  226. code: loginRes.code,
  227. encryptedData: infoRes.encryptedData,
  228. iv: infoRes.iv,
  229. appId: getApp().globalData.appId
  230. }).then(res => {
  231. uni.hideLoading();
  232. if (res.code == 200) {
  233. // this.checkUserInfoA()
  234. this.$store.commit('setCoureLogin', 1);
  235. uni.setStorageSync(
  236. 'AppTokenmini_RTCourse', res
  237. .token);
  238. uni.setStorageSync('auto_userInfo',
  239. JSON.stringify(res.user));
  240. this.isLogin = true
  241. // if(this.chatId!=''||this.chatId){
  242. // this.userlogo=true
  243. // }else{
  244. // this.getLuckyBagInfo()
  245. // }
  246. this.receiveLuckyBag()
  247. } else {
  248. uni.showToast({
  249. title: res.msg,
  250. icon: 'none'
  251. });
  252. }
  253. }).catch(err => {
  254. uni.hideLoading();
  255. uni.showToast({
  256. icon: 'none',
  257. title: "登录失败,请重新登录",
  258. });
  259. });
  260. }
  261. });
  262. }
  263. })
  264. }).catch(err => {})
  265. }
  266. }
  267. }
  268. </script>
  269. <style scoped lang="scss">
  270. .exsct {
  271. height: 92rpx;
  272. width: 437rpx;
  273. background-color: transparent;
  274. border-radius: 69rpx;
  275. position: absolute;
  276. top: 27rpx;
  277. left: 28rpx;
  278. box-shadow: inset -57rpx 0px 40rpx -26rpx rgba(255, 255, 255, 0.7);
  279. will-change: left, opacity;
  280. animation: leftFade 2s linear infinite;
  281. opacity: 0;
  282. }
  283. .color_FB2205 {
  284. color: #FB2205;
  285. }
  286. .activity_title2,
  287. .activity_title3,
  288. .activity_title4 {
  289. margin-top: 8vh;
  290. margin-bottom: 56rpx;
  291. font-family: PingFang SC, PingFang SC;
  292. font-weight: 600;
  293. font-size: 48rpx;
  294. line-height: 80rpx;
  295. filter: drop-shadow(0px 4rpx 8rpx rgba(174, 0, 25, 0.8));
  296. text-align: center;
  297. font-style: normal;
  298. text-transform: none;
  299. background: linear-gradient(270deg, #FFF5EE 0%, #FFE2B3 100%);
  300. -webkit-background-clip: text;
  301. background-clip: text;
  302. -webkit-text-fill-color: transparent;
  303. text-fill-color: transparent;
  304. display: inline-block
  305. }
  306. .activity_title3 {
  307. font-size: 48rpx;
  308. line-height: 80rpx;
  309. margin-top: 6vh;
  310. margin-bottom: 8rpx;
  311. }
  312. .activity_title4 {
  313. font-size: 32rpx;
  314. line-height: 44rpx;
  315. margin-top: 0;
  316. margin-bottom: 48rpx;
  317. }
  318. .container_box {
  319. min-height: 100vh;
  320. position: relative;
  321. background: linear-gradient(180deg, #FD2F3C 0%, #FFE7CE 100%);
  322. }
  323. .activity_yh_right {
  324. width: 100rpx;
  325. position: absolute;
  326. top: 25%;
  327. right: 0;
  328. }
  329. .activity_yh_left {
  330. width: 114rpx;
  331. position: absolute;
  332. top: 50%;
  333. left: 0;
  334. }
  335. .header-nav {
  336. height: 88rpx;
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. overflow: hidden;
  341. box-sizing: border-box;
  342. width: 100%;
  343. }
  344. .conbox {
  345. position: relative;
  346. display: flex;
  347. flex-direction: column;
  348. align-items: center;
  349. justify-content: flex-start;
  350. z-index: 3;
  351. .activity_title {
  352. width: 632rpx;
  353. height: auto;
  354. margin-top: 28rpx;
  355. }
  356. .ybg_box {
  357. width: 566rpx;
  358. height: 580rpx;
  359. position: relative;
  360. .activity_ysx,
  361. .activity_ylq {
  362. position: absolute;
  363. left: 242rpx;
  364. top: 215rpx;
  365. width: 300rpx;
  366. height: auto;
  367. }
  368. .ybg {
  369. width: 616rpx;
  370. height: 616rpx;
  371. background: #FFE7CE;
  372. border-radius: 0rpx 0rpx 0rpx 0rpx;
  373. filter: blur(94.30000305175781px);
  374. }
  375. image {
  376. height: 580rpx;
  377. position: absolute;
  378. top: 0;
  379. left: 0;
  380. z-index: 99;
  381. }
  382. }
  383. .activity_btn_down {
  384. width: 416rpx;
  385. height: 88rpx;
  386. margin-top: 94rpx;
  387. background: rgba(0, 0, 0, 0.3);
  388. border-radius: 56rpx 56rpx 56rpx 56rpx;
  389. font-family: PingFang SC, PingFang SC;
  390. font-weight: 600;
  391. font-size: 28rpx;
  392. color: #FFFFFF;
  393. image {
  394. width: 32rpx;
  395. height: 32rpx;
  396. margin-left: 16rpx;
  397. }
  398. }
  399. .activity_btn {
  400. height: 137rpx;
  401. width: 502rpx;
  402. margin-top: 48rpx;
  403. font-family: PingFang SC;
  404. font-weight: 600;
  405. font-size: 44rpx;
  406. color: #FFFFFF;
  407. display: flex;
  408. align-items: center;
  409. justify-content: center;
  410. position: relative;
  411. z-index: 2;
  412. overflow: hidden;
  413. border-radius: 137rpx;
  414. image {
  415. height: 137rpx;
  416. position: absolute;
  417. left: 0;
  418. top: 12rpx;
  419. z-index: -1;
  420. }
  421. }
  422. }
  423. .popup-box {
  424. width: 518rpx;
  425. min-height: 568rpx;
  426. background: linear-gradient(180deg, #FFE7AC 0%, #FFFFFF 100%);
  427. border-radius: 56rpx 56rpx 56rpx 56rpx;
  428. position: relative;
  429. display: flex;
  430. align-items: center;
  431. flex-direction: column;
  432. box-shadow: 0 0 30px -6px rgba(255, 231, 206, 1);
  433. .activity_jb {
  434. height: 184rpx;
  435. margin-top: -130rpx;
  436. position: relative;
  437. }
  438. .popup-tit {
  439. font-family: PingFang SC;
  440. font-weight: 600;
  441. font-size: 40rpx;
  442. color: #000000;
  443. line-height: 80rpx;
  444. }
  445. .con {
  446. margin-top: 16rpx;
  447. width: 438rpx;
  448. min-height: 170rpx;
  449. padding: 16rpx 0;
  450. background: #FFE8AE;
  451. border-radius: 16rpx 16rpx 16rpx 16rpx;
  452. font-family: PingFang SC;
  453. font-weight: 400;
  454. font-size: 28rpx;
  455. color: #333333;
  456. display: flex;
  457. flex-direction: column;
  458. align-items: center;
  459. justify-content: center;
  460. }
  461. .numbox {
  462. font-weight: 600;
  463. margin-bottom: 12rpx;
  464. }
  465. .num {
  466. font-size: 68rpx;
  467. margin-right: 10rpx;
  468. }
  469. .popbtn {
  470. width: 358rpx;
  471. height: 88rpx;
  472. background: linear-gradient(90deg, #F82D31 0%, #FD6C05 100%);
  473. box-shadow: 0rpx 8rpx 0rpx 0rpx #FEBC92;
  474. border-radius: 64rpx 64rpx 64rpx 64rpx;
  475. margin-top: 32rpx;
  476. font-family: PingFang SC, PingFang SC;
  477. font-weight: 600;
  478. font-size: 32rpx;
  479. color: #FFFFFF;
  480. }
  481. }
  482. .popup-tips {
  483. margin-top: 20rpx;
  484. font-family: PingFang SC;
  485. font-weight: 400;
  486. font-size: 24rpx;
  487. color: #666666;
  488. text-align: center;
  489. }
  490. .footer_img {
  491. width: 100%;
  492. position: fixed;
  493. bottom: 0;
  494. left: 0;
  495. }
  496. .animation {
  497. will-change: transform;
  498. animation: scaleAnimation 2s ease infinite;
  499. }
  500. @keyframes leftFade {
  501. 0% {
  502. left: -464rpx;
  503. opacity: 0;
  504. }
  505. 25% {
  506. opacity: 1;
  507. left: -249rpx;
  508. }
  509. 50% {
  510. opacity: 0;
  511. left: 16rpx;
  512. }
  513. 100% {
  514. opacity: 0;
  515. left: 490rpx;
  516. }
  517. }
  518. @keyframes scaleAnimation {
  519. 0% {
  520. transform: scale(1);
  521. }
  522. // 30% {
  523. // transform: scale(1.05);
  524. // }
  525. 50% {
  526. transform: scale(1.05);
  527. }
  528. 100% {
  529. transform: scale(1);
  530. }
  531. }
  532. </style>