extractBookCurr.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <view class="extractBook">
  3. <u-navbar :customBack="goBack" back-text="返回" title="提取书币"></u-navbar>
  4. <view class="bookCurrs">
  5. <view class="topContent">
  6. <text class="title">书币提取</text>
  7. <text style="color: #FE604F;" @click="ruleShow = true">提取规则</text>
  8. </view>
  9. <view class="bottomContent">
  10. <view class="balance">余额:{{balance}}</view>
  11. <view class="bookCurrList">
  12. <view v-for="item in bookCurrList" :key="item.id" :class="item.id === bookCurrId ? 'select' : ''" @click="selectHandle(item)">
  13. <image src="../../static/gold.png" class="goldCoins" style="width: 68rpx;" mode="heightFix"></image>
  14. <text class="reward">{{item.value}}书币</text>
  15. </view>
  16. </view>
  17. <view class="bookCurrNum">{{bookCurrNum}}书币</view>
  18. <view class="extractButton" @click="extractHandle">
  19. 立即提取
  20. </view>
  21. <navigator :url="`../extractRecord/extractRecord?mpAppId=${mpData.mpAppId}&mpOpenId=${mpData.mpOpenId}`" class="extractRecord" v-if="mpData.mpAppId" hover-class="none">提取记录</navigator>
  22. </view>
  23. </view>
  24. <!-- 规则弹窗 -->
  25. <u-popup v-model="ruleShow" mode="center" :closeable="true" border-radius="18" close-icon-color="#FFF" @close="ruleShow=false" custom-style="{backgroundColor: #DC8182}">
  26. <view class="popupCenter">
  27. <view class="popupTitle">提取书币规则</view>
  28. <view class="bottom">
  29. <view>
  30. 1.用户每日可解锁书币余额“提取”功能。
  31. </view>
  32. <view>
  33. 2.解锁提取功能后,我们为您提供多个固定提取额度,具体提取额度以当日提取页面提供的具体提取额度为准。
  34. </view>
  35. <view>
  36. 3.每次提取时,您可以选择所需的其中一档提取额度进行提取,剩余书币可在下次满足前述提取额度时申请提取。
  37. </view>
  38. <view>
  39. 4.点击“书币余额提取”后,请前往公众号点击链接领取书币(链接有效期为3天)。
  40. </view>
  41. <view>
  42. 5.书币领取链接通常会在24小时内到达公众号,若点击提取书币后2小时无反应,请前往公众号发送关键字“领取书币”。
  43. </view>
  44. <view>
  45. 6.请您理解并同意如遇到双休日,节假日或提取高峰期,书币提取链接发送时间可能会延长,请您耐心等待。
  46. </view>
  47. <view>
  48. 7.本活动解释权由开发者所有,有任何疑问请联系公众号内客服。
  49. </view>
  50. </view>
  51. </view>
  52. </u-popup>
  53. <!-- 次数用完弹窗 -->
  54. <u-popup v-model="countShow" mode="center" :closeable="true" border-radius="18" close-icon-color="#000" @close="countShow=false">
  55. <view class="popupCount">
  56. <image src="../../static/noCountGold.png" mode="heightFix"></image>
  57. <text class="title">今日次数已用完,明日再来~</text>
  58. <text class="subTitle">提醒:每日只能提取一次</text>
  59. <button type="default" class="bt" @click="countShow=false">我知道了</button>
  60. </view>
  61. </u-popup>
  62. <!-- 提取成功弹窗 -->
  63. <view class="popup" v-if="succShow">
  64. <view class="popupContent">
  65. <view class="content">
  66. <image src="../../static/popupBack.png"></image>
  67. <view class="textCon">
  68. <text class="ts">书币已提取,请前往公众号点击链接领取书币</text> </br>
  69. <view class="bt" @click="succShow=false">我知道了</view>
  70. </view>
  71. </view>
  72. <image src="../../static/close.png" class="close" mode="widthFix" @click="succShow=false"></image>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. /**
  78. * 体现页面
  79. *
  80. ***/
  81. <script>
  82. import { config, getBalance, getQuotaList, setCoinRemove } from '@/api/api.js'
  83. export default {
  84. data() {
  85. return {
  86. ruleShow: false, // 规则弹窗控制
  87. countShow: false, // 次数用完弹窗
  88. succShow: false, // 提取成功弹窗
  89. bookCurrList: [],// 数据列表
  90. bookCurrId: undefined, // 选择充值项
  91. bookCurrNum: undefined, // 选择的书币数量
  92. balance: 0, // 余额
  93. mpData: {}
  94. }
  95. },
  96. onLoad(opt) {
  97. console.log(opt)
  98. this.mpData = opt
  99. this.getList()
  100. this.getData()
  101. },
  102. onUnload() {
  103. console.log('销毁')
  104. let pages = getCurrentPages();
  105. let prevPage = pages[pages.length - 2]; //上一个页面
  106. prevPage.$vm.getBookCurr();//重点$vm
  107. },
  108. methods: {
  109. goBack() {
  110. uni.navigateBack();
  111. },
  112. selectHandle(item) {
  113. this.bookCurrNum = item.value
  114. this.bookCurrId = item.id
  115. },
  116. getData() {
  117. getBalance({...this.mpData, appId: config.appid}).then(res => {
  118. this.balance = res.data || 0
  119. })
  120. },
  121. getList() {
  122. getQuotaList({mpAppId: this.mpData.mpAppId}).then(res => {
  123. this.bookCurrList = res.data || []
  124. if(res.data.length > 0) {
  125. this.bookCurrId = res.data[0].id
  126. this.bookCurrNum = res.data[0].value
  127. }
  128. })
  129. },
  130. /** 提现*/
  131. extractHandle() {
  132. if (this.bookCurrNum > this.balance) {
  133. uni.showToast({
  134. title: '余额不足,请选择其它数量提取',
  135. icon: 'none'
  136. })
  137. return
  138. }
  139. setCoinRemove({...this.mpData, appId: config.appid, bookCoinId: this.bookCurrId}).then(res => {
  140. switch(res.data) {
  141. case 0:
  142. // uni.showToast({
  143. // title: '提取成功'
  144. // })
  145. this.succShow = true
  146. this.getData()
  147. break;
  148. case 1:
  149. uni.showToast({
  150. title: '提取失败, 请在公众号发送任意消息预约, 再来提取',
  151. icon: 'error'
  152. })
  153. break;
  154. case 2:
  155. this.countShow = true
  156. break;
  157. }
  158. })
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss">
  164. page {
  165. // background-color: #F2F2F2;
  166. background-color: #FC6E53;
  167. }
  168. .extractBook {
  169. .bookCurrs {
  170. background-color: #FFFFFF;
  171. margin: 30rpx 14rpx;
  172. border-radius: 22rpx;
  173. min-height: 200rpx;
  174. padding: 20rpx 0 30rpx;
  175. box-sizing: border-box;
  176. }
  177. .topContent {
  178. padding: 0 24rpx 20rpx;
  179. border-bottom: 1rpx solid #eee;
  180. display: flex;
  181. justify-content: space-between;
  182. align-items: center;
  183. .title {
  184. font-size: 38rpx;
  185. font-weight: 600;
  186. }
  187. }
  188. .bottomContent {
  189. padding: 40rpx 24rpx 0;
  190. .balance {
  191. font-size: 38rpx;
  192. font-weight: 600;
  193. }
  194. .bookCurrNum {
  195. color: #FE604F;
  196. font-size: 38rpx;
  197. font-weight: 600;
  198. margin-top: 26rpx;
  199. }
  200. .bookCurrList {
  201. margin-top: 20rpx;
  202. display: grid;
  203. grid-template-columns: 1fr 1fr 1fr 1fr;
  204. grid-gap: 20rpx;
  205. &>view{
  206. width: 152rpx;
  207. height: 168rpx;
  208. background-color: #FFFFFF;
  209. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(182, 182, 182, 0.3);
  210. border: 2rpx solid #ececec;
  211. border-radius: 16rpx;
  212. padding: 12rpx;
  213. box-sizing: border-box;
  214. display: flex;
  215. flex-direction: column;
  216. justify-content: flex-start;
  217. align-items: center;
  218. position: relative;
  219. &.select {
  220. background: #FFF7EF;
  221. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(254, 173, 165, 0.26);
  222. border: 2rpx solid #FFB35C;
  223. .reward{
  224. color: #FE604F;
  225. }
  226. }
  227. }
  228. .goldCoins {
  229. height: 68rpx;
  230. margin: 5rpx 0;
  231. }
  232. .reward{
  233. font-size: 28rpx;
  234. font-weight: 500;
  235. color: #000000;
  236. margin-top: 16rpx;
  237. }
  238. }
  239. .extractButton {
  240. // width: 456rpx;
  241. height: 80rpx;
  242. margin-top: 60rpx;
  243. font-size: 34rpx;
  244. color: #FFFFFF;
  245. font-weight: 500;
  246. text-align: center;
  247. display: flex;
  248. justify-content: center;
  249. align-items: center;
  250. border-radius: 40rpx;
  251. // background-color: #000000;
  252. background: linear-gradient(180deg, #FDC606 0%, #FF8D12 100%);
  253. box-sizing: border-box;
  254. }
  255. .extractRecord {
  256. text-align: center;
  257. color: #5084f5;
  258. margin-top: 24rpx;
  259. }
  260. }
  261. .popupCenter {
  262. width: 650rpx;
  263. // height: 800rpx;
  264. padding: 26rpx;
  265. background-color: #DC8182;
  266. color: #FFFFFF;
  267. .popupTitle {
  268. font-size: 36rpx;
  269. font-weight: 600;
  270. color: #FFFFFF;
  271. text-align: center;
  272. }
  273. .bottom {
  274. margin-top: 30rpx;
  275. padding: 0 28rpx 30rpx;
  276. box-sizing: border-box;
  277. &> view {
  278. margin-bottom: 12rpx;
  279. font-size: 28rpx;
  280. font-weight: 400;
  281. color: #FFFFFF;
  282. line-height: 46rpx;
  283. }
  284. }
  285. }
  286. .popupCount {
  287. width: 540rpx;
  288. padding: 60rpx 0 0;
  289. // background-color: #DC8182;
  290. // color: #FFFFFF;
  291. min-height: 100rpx;
  292. display: flex;
  293. flex-direction: column;
  294. align-items: center;
  295. &>image {
  296. height: 200rpx;
  297. }
  298. &>.title {
  299. margin-top: 28rpx;
  300. font-size: 36rpx;
  301. }
  302. &>.subTitle {
  303. color: #909090;
  304. margin-top: 20rpx;
  305. font-size: 24rpx;
  306. }
  307. &>.bt {
  308. margin-top: 30rpx;
  309. width: 100%;
  310. border-radius: 0;
  311. background-color: #FFFFFF;
  312. &::after {
  313. border-top-left-radius: 0;
  314. border-top-right-radius: 0;
  315. border-left-width: 0;
  316. border-right-width: 0;
  317. border-bottom-width: 0;
  318. }
  319. }
  320. }
  321. }
  322. .popup {
  323. position: fixed;
  324. width: 100%;
  325. height: 100vh;
  326. background: rgba(0, 0, 0, 0.6);
  327. top: 0;
  328. left: 0;
  329. right: 0;
  330. bottom: 0;
  331. .popupContent {
  332. width: 632rpx;
  333. position: absolute;
  334. top: 50%;
  335. left: 50%;
  336. transform: translate(-50%, -50%);
  337. text-align: center;
  338. &>.content {
  339. position: relative;
  340. &>image {
  341. width: 100%;
  342. height: 652rpx;
  343. }
  344. &>.textCon {
  345. position: absolute;
  346. width: 100%;
  347. top: 0;
  348. left: 0;
  349. right: 0;
  350. bottom: 0;
  351. padding: 192rpx 106rpx 0;
  352. box-sizing: border-box;
  353. display: flex;
  354. align-items: center;
  355. flex-direction: column;
  356. .ts {
  357. font-size: 40rpx;
  358. font-weight: 500;
  359. color: #F5631D;
  360. }
  361. .reward {
  362. height: 60rpx;
  363. background: #FFD9A2;
  364. border-radius: 31rpx;
  365. font-size: 32rpx;
  366. font-weight: 400;
  367. display: inline-block;
  368. padding: 0 32rpx;
  369. color: #F5631E;
  370. line-height: 60rpx;
  371. margin-top: 20rpx;
  372. }
  373. .doubleBt {
  374. width: 456rpx;
  375. height: 104rpx;
  376. margin-top: 90rpx;
  377. transition: all linear .5s;
  378. }
  379. .bt {
  380. width: 386rpx;
  381. height: 104rpx;
  382. text-align: center;
  383. line-height: 104rpx;
  384. margin-top: 184rpx;
  385. font-size: 36rpx;
  386. font-weight: 400;
  387. color: rgba(131, 25, 2, 1);
  388. box-shadow: 0rpx 3rpx 4rpx 0rpx rgba(211, 63, 22, 0.58);
  389. background-color: #fede77;
  390. border-radius: 52rpx;
  391. }
  392. }
  393. }
  394. &>.close {
  395. width: 54rpx;
  396. height: 54rpx;
  397. margin-top: 76rpx;
  398. }
  399. }
  400. }
  401. </style>