integral.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <template>
  2. <view>
  3. <hua-pageBg></hua-pageBg>
  4. <view class="wrapper">
  5. <view class="page-head d-flex justify-content-between align-items-center">
  6. <router-link to="/pages/integral/details">
  7. <view class="record">券明细</view>
  8. </router-link>
  9. <view class="title text-center">券商城</view>
  10. <router-link to="/pages/integral/rules">
  11. <view class="rule">规则</view>
  12. </router-link>
  13. </view>
  14. <view class="djs" v-if="isshow != 0">
  15. <view class="djs-main" v-if="isshow ==1">释放券倒计时:{{ countdown_time }}</view>
  16. <view class="djs-main" v-if="isshow ==2">释放券倒计时:已过期</view>
  17. </view>
  18. <view class="integral">
  19. <view class="top d-flex align-items-center">
  20. <view class="item d-flex align-items-center">
  21. <image src="../../static/jifen/jb.png" mode="heightFix"></image>
  22. <text class="num">{{ userInfo.user_integral ? userInfo.user_integral : 0 }}</text>
  23. </view>
  24. <view class="item d-flex align-items-center">
  25. <image src="../../static/jifen/nl.png" mode="heightFix"></image>
  26. <text class="num">{{ userInfo.energy ? userInfo.energy : 0 }}</text>
  27. <view class="status" v-if="userInfo.is_energy && userInfo.is_energy == 1">已激活</view>
  28. <view class="status" v-else>未激活</view>
  29. </view>
  30. </view>
  31. <view class="wrap bg-white">
  32. <!-- <view class="today">
  33. 今日券抵用券兑换比例:
  34. <text>100券={{ (this.appConfig.energyprice * 100).toFixed(5) }}抵用券</text>
  35. </view>
  36. <view class="trans_num text-center">
  37. 1抵用券 =
  38. <text>{{ this.appConfig.energyprice }}券</text>
  39. </view> -->
  40. <!-- <view class="title">
  41. 券兑换抵用券
  42. </view>
  43. <view class="sub">
  44. 券兑换抵用券即可免费获得商品
  45. </view>
  46. <view class="transformation d-flex align-items-center justify-content-between">
  47. <view class="int-item d-flex align-items-center">
  48. <image src="../../static/jifen/jb.png" mode="heightFix"></image>
  49. <input type="text" placeholder="输入券值" v-model="intergral" @input="onInput">
  50. </view>
  51. <image src="../../static/jifen/dy.png" mode="widthFix" class="dy"></image>
  52. <view class="int-item d-flex align-items-center">
  53. <image src="../../static/jifen/nl.png" mode="heightFix"></image>
  54. <input type="text" placeholder="换算抵用券" disabled="true" v-model="energy">
  55. </view>
  56. </view>
  57. <view class="submit" @tap="exchange">
  58. 立即兑换
  59. </view>
  60. <view class="tips">
  61. 券兑换抵用券计算公式
  62. </view> -->
  63. <view class="task-wrap">
  64. <view class="title">做任务领券</view>
  65. <view class="task-list d-flex justify-content-between align-items-center"
  66. v-if="!userInfo.is_energy || userInfo.is_energy == 0">
  67. <view class="logo">
  68. <image src="../../static/jifen/icon4.png" mode=""></image>
  69. </view>
  70. <view class="cont">
  71. <view class="tit">激活抵用券</view>
  72. <view class="desc">购买爆单区商品即可激活抵用券</view>
  73. </view>
  74. <view class="btn" @click="toExplosive">去激活</view>
  75. </view>
  76. <router-link :to="{ path: item.url }"
  77. class="task-list d-flex justify-content-between align-items-center"
  78. v-for="(item, index) in taskList" :key="index">
  79. <view class="logo">
  80. <image :src="item.logo" mode=""></image>
  81. </view>
  82. <view class="cont">
  83. <view class="tit">{{ item.title }}</view>
  84. <view class="desc">{{ item.desc }}</view>
  85. </view>
  86. <view class="btn">去看看</view>
  87. </router-link>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="container">
  92. <!-- <view class="one-list">
  93. <u-sticky>
  94. <u-tabs :list="oneList" lineColor="#F8352B" :activeStyle="{color: '#F8352B',fontWeight: 'bold',}" lineWidth="40" lineHeight="4"></u-tabs>
  95. </u-sticky>
  96. </view> -->
  97. <view class="energy-product">
  98. <mescroll-body ref="mescrollRef" :height="400" :up="{
  99. noMoreSize: 10,
  100. empty: {
  101. icon: '/static/images/order_null.png',
  102. tip: '暂无更多内容~',
  103. fixed: false
  104. }
  105. }" @init="mescrollInit" @down="downCallback" @up="upCallback">
  106. <hua-power-product :data="productList"></hua-power-product>
  107. </mescroll-body>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. import {
  115. apiEnergy,
  116. exchangeEnergy,
  117. getGoodsDiscountList
  118. } from '@/api/shop.js';
  119. import {
  120. getUser
  121. } from '@/api/user.js'
  122. import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
  123. import {
  124. mapGetters,
  125. mapActions
  126. } from 'vuex';
  127. const app = getApp();
  128. export default {
  129. mixins: [MescrollMixin],
  130. data() {
  131. return {
  132. taskList: [{
  133. logo: '../../static/jifen/icon.png',
  134. title: '购买商品立即获取券',
  135. desc: '购买商品立即获取券',
  136. url: '/pages/goods_explosive/goods_explosive'
  137. },
  138. {
  139. logo: '../../static/jifen/icon2.png',
  140. title: '看视频立即获取券',
  141. desc: '看视频立即获取券',
  142. url: '/pages/ad-video/ad-video'
  143. },
  144. {
  145. logo: '../../static/jifen/icon3.png',
  146. title: '商家赠送立即获取券',
  147. desc: '商家赠送立即获取券',
  148. url: '/pages/user/energy-transfer?type=2'
  149. }
  150. ],
  151. oneList: [],
  152. productList: [],
  153. intergral: '',
  154. energy: '',
  155. info: '',
  156. isshow: 0,
  157. countdown_time: '',
  158. timers: ''
  159. };
  160. },
  161. onShow() {
  162. this.getInfo()
  163. // this.getGoods()
  164. },
  165. onHide() {
  166. clearTimeout(this.timers);
  167. },
  168. // 监听页面卸载
  169. onUnload() {
  170. // 关闭倒计时
  171. clearTimeout(this.timers);
  172. },
  173. // 监听页面后退
  174. onBackPress() {
  175. // 关闭倒计时
  176. clearTimeout(this.timers);
  177. },
  178. methods: {
  179. onInput(e) {
  180. console.log(e.detail);
  181. this.energy = e.detail.value * this.appConfig.energyprice;
  182. },
  183. getInfo() {
  184. const obj = this
  185. getUser().then(e => {
  186. this.info = e.data
  187. let data = new Date();
  188. let newTime = data.getTime();
  189. console.log(this.info, '123456');
  190. if (this.info.level > 0) {
  191. obj.isshow = 1
  192. if ((this.info.activity_time + 30 * 24 * 60 * 60) * 1000 < newTime) {
  193. obj.isshow = 2
  194. } else {
  195. obj.counTime()
  196. }
  197. }
  198. })
  199. },
  200. counTime() {
  201. //获取当前时间
  202. let data = new Date();
  203. let newTime = data.getTime();
  204. //结束时间
  205. let end = this.info.activity_time + 30 * 24 * 60 * 60;
  206. //时间差
  207. let leftTime = end * 1000 - newTime;
  208. console.log(leftTime);
  209. if (leftTime <= 0) {
  210. this.isshow = 2
  211. console.log('已结束');
  212. return;
  213. }
  214. //定义保存倒计时时间
  215. let d, h, m, s;
  216. if (leftTime >= 0) {
  217. d = Math.floor(leftTime / (1000 * 60 * 60 * 24))
  218. h = Math.floor((leftTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
  219. m = Math.floor((leftTime / 1000 / 60) % 60);
  220. s = Math.floor((leftTime / 1000) % 60);
  221. console.log(m, s);
  222. //倒计时赋值view
  223. this.countdown_time = `${d}天${h}时${m}分${s}秒`;
  224. this.timers = setTimeout(this.counTime, 1000);
  225. }
  226. },
  227. toExplosive() {
  228. uni.navigateTo({
  229. url: '/pages/goods_explosive/goods_explosive'
  230. });
  231. },
  232. async exchange() {
  233. console.log(this.userInfo.is_energy);
  234. // if(this.intergral == ''){
  235. // uni.showToast({
  236. // title:"请输入券数量",
  237. // icon:"none"
  238. // })
  239. // return;
  240. // }
  241. // if(this.userInfo.is_energy != 1){
  242. // uni.showToast({
  243. // title:'请先激活抵用券',
  244. // icon:"none"
  245. // })
  246. // return;
  247. // }
  248. // const {
  249. // data,
  250. // code
  251. // } = await exchangeEnergy({
  252. // num:this.intergral
  253. // })
  254. // if(code == 1){
  255. // console.log(data)
  256. // uni.showToast({
  257. // title:data.msg
  258. // })
  259. // this.getUser()
  260. // }
  261. },
  262. // async getGoods() {
  263. // const {
  264. // code,
  265. // data
  266. // } = await getGoodsDiscountList({
  267. // page_no: this.formData.page_no,
  268. // page_size: this.formData.page_size
  269. // })
  270. // if (code == 1) {
  271. // this.productList = data.lists
  272. // }
  273. // console.log(data)
  274. // },
  275. // 上拉加载更多
  276. upCallback({
  277. num,
  278. size
  279. }) {
  280. getGoodsDiscountList({
  281. page_no: num,
  282. page_size: size
  283. })
  284. .then(({
  285. data,
  286. code
  287. }) => {
  288. if (code != 1) return this.mescroll.endErr();
  289. if (num === 1) this.productList = [];
  290. this.productList = [...this.productList, ...data.lists];
  291. this.mescroll.endSuccess(data.lists.length, !!data.more);
  292. })
  293. .catch(err => {
  294. this.mescroll.endErr();
  295. });
  296. }
  297. },
  298. computed: {
  299. ...mapGetters(['appConfig', 'userInfo'])
  300. }
  301. };
  302. </script>
  303. <style lang="scss">
  304. .container {
  305. padding: 0 24rpx;
  306. }
  307. .wrapper {
  308. position: relative;
  309. z-index: 2;
  310. }
  311. .page-head {
  312. padding: 0 24upx;
  313. height: 80upx;
  314. font-size: 28upx;
  315. position: relative;
  316. .title {
  317. font-size: 32upx;
  318. font-weight: bold;
  319. flex: 1;
  320. position: absolute;
  321. left: 50%;
  322. top: 50%;
  323. transform: translate(-50%, -50%);
  324. }
  325. }
  326. .integral {
  327. padding: 0 30upx;
  328. box-sizing: border-box;
  329. .top {
  330. background: url('https://shop.xianghuaqi.net.cn/images/bg.png') no-repeat;
  331. height: 100upx;
  332. padding: 0 30upx 20upx;
  333. background-size: 100%;
  334. image {
  335. height: 48upx;
  336. }
  337. .item {
  338. margin-right: 30upx;
  339. text {
  340. font-family: Impact;
  341. font-size: 48upx;
  342. margin-left: 10upx;
  343. color: #904c18;
  344. }
  345. &:last-child text {
  346. color: #1c80eb;
  347. }
  348. .status {
  349. background-color: #fff;
  350. border-radius: 18rpx;
  351. color: #3992f8;
  352. font-size: 20rpx;
  353. padding: 0 16rpx;
  354. margin-left: 20rpx;
  355. }
  356. }
  357. }
  358. .wrap {
  359. padding: 30upx 24upx;
  360. box-sizing: border-box;
  361. border-radius: 20upx;
  362. margin-top: -20upx;
  363. .trans_num {
  364. font-size: 36rpx;
  365. font-weight: bold;
  366. text {
  367. color: #f73e33;
  368. }
  369. }
  370. .today {
  371. background: #f2f8ff;
  372. border-radius: 12upx;
  373. font-size: 24upx;
  374. height: 60upx;
  375. line-height: 60upx;
  376. text-align: center;
  377. margin-bottom: 20upx;
  378. text {
  379. color: #2b89f2;
  380. }
  381. }
  382. .title {
  383. font-weight: 700;
  384. font-size: 36upx;
  385. color: #040404;
  386. line-height: 50upx;
  387. }
  388. .sub {
  389. line-height: 40upx;
  390. font-size: 24upx;
  391. font-weight: 400;
  392. color: #aaaaaa;
  393. }
  394. .transformation {
  395. margin: 30upx auto 56upx;
  396. .int-item {
  397. background-color: #f7f8fa;
  398. width: 280upx;
  399. height: 100upx;
  400. border-radius: 12upx;
  401. padding-left: 40upx;
  402. box-sizing: border-box;
  403. image {
  404. height: 34upx;
  405. }
  406. input {
  407. color: #aaaaaa;
  408. font-size: 28upx;
  409. margin-left: 10upx;
  410. flex: 1;
  411. }
  412. }
  413. .dy {
  414. width: 40upx;
  415. }
  416. }
  417. .submit {
  418. background: linear-gradient(142deg, #f16d60 0%, #f8352b 100%);
  419. width: 384upx;
  420. height: 80upx;
  421. line-height: 80upx;
  422. text-align: center;
  423. color: #fff;
  424. margin: 0 auto;
  425. border-radius: 42upx;
  426. }
  427. .tips {
  428. color: #aaaaaa;
  429. margin-top: 12upx;
  430. font-size: 24upx;
  431. text-align: center;
  432. }
  433. .task-wrap {
  434. margin-top: 40upx;
  435. .task-list {
  436. margin: 20upx auto;
  437. .logo {
  438. width: 90upx;
  439. height: 92upx;
  440. image {
  441. width: 100%;
  442. height: 100%;
  443. }
  444. }
  445. .cont {
  446. flex: 1;
  447. margin: 0 20upx;
  448. .tit {
  449. line-height: 60upx;
  450. font-weight: 700;
  451. font-size: 28upx;
  452. }
  453. .desc {
  454. color: #616161;
  455. font-size: 24upx;
  456. }
  457. }
  458. .btn {
  459. background: linear-gradient(151deg, #f8d360 0%, #f6c93d 100%);
  460. border-radius: 15px;
  461. font-size: 28upx;
  462. color: #fff;
  463. width: 162upx;
  464. height: 58upx;
  465. text-align: center;
  466. line-height: 58upx;
  467. }
  468. &:last-child {
  469. margin-bottom: 0;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. .one-list {
  476. margin: 20upx auto;
  477. }
  478. .energy-product {
  479. margin: 20rpx auto;
  480. }
  481. .djs-main {
  482. margin: 20rpx 0;
  483. font-size: 40rpx;
  484. text-align: center;
  485. color: #fd3b39;
  486. }
  487. </style>