index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <view class="container">
  3. <!-- 用户信息 -->
  4. <view class="userinfo flex_r flex_ac">
  5. <image class="user_img" :src="userinfo.head_pic" mode=""></image>
  6. <view class="user_info flex_c flex_jc">
  7. <view class="user_name">{{ userinfo.nickname }}</view>
  8. <view class="level_con flex_r flex_ac">
  9. <view class="level">{{ userinfo.level_name }}</view>
  10. </view>
  11. </view>
  12. <!-- <view class="record flex_r flex_ac flex_jc" @tap="NavToSignList">积分记录</view> -->
  13. </view>
  14. <!-- 用户信息-end -->
  15. <!-- 签到信息 -->
  16. <view class="sign_info flex_c">
  17. <view class="info flex_r flex_ac flex_jb">
  18. <view class="info_today flex_c flex_ac">
  19. <view class="today_text g_color">{{todaySign}}</view>
  20. <view class="info_text">今日签到</view>
  21. </view>
  22. <view class="info_today flex_c flex_ac">
  23. <view class="today_text">{{todaySign}}</view>
  24. <view class="info_text">累计签到({{totalSign || 0}}次)</view>
  25. </view>
  26. <view class="info_con">
  27. <image class="info_img" :src="nextSign> 0 ? '/static/sgin/p_back2.png' : '/static/sgin/p_back.png'" mode=""></image>
  28. <view class="info_texts flex_r flex_ac flex_jc" @tap="setSignIn">{{nextSign > 0 ? timer : ''}}<text v-if="nextSign <= 0">立即签到</text></view>
  29. </view>
  30. </view>
  31. <view class="sign_time flex_r flex_ac flex_je mar_t20">
  32. <text></text>
  33. </view>
  34. </view>
  35. <!-- 签到信息-end -->
  36. <!-- 精品推荐 -->
  37. <view class="bou_head flex_r flex_ac flex_jc">
  38. <image class="bou_img" src="/static/sgin/left.png" mode=""></image>
  39. <view class="bou_title">精品推荐</view>
  40. <image class="bou_img" src="/static/sgin/right.png" mode=""></image>
  41. </view>
  42. <view class="product-list">
  43. <view class="product" v-for="(i, s) in goods" :key="s" @click="NavToGoodsDetail(i.id,i.type)">
  44. <view class="image-view">
  45. <image class="product-image" :src="i.original_img"></image>
  46. </view>
  47. <view :class="['product-title', 'ellipsis1']">{{ i.goods_name }}</view>
  48. <view class="product-price">
  49. <text class="product-price-original"><text class="product-unit">¥</text>{{ i.price }}</text>
  50. <!-- <text class="product-price-favour">¥{{i.originalPrice}}</text> -->
  51. <!-- <text class="product-tip">{{i.tip}}</text> -->
  52. </view>
  53. <view class="product-txt">赠送{{ i.give_integral ? i.give_integral + '批发积分' : i.give_cha_bao + '茶宝'}}</view>
  54. </view>
  55. <view class='fz_w_text mar_t20 mar_b20'>让数字经济赋能美好生活!</view>
  56. </view>
  57. <!-- 精品推荐-end -->
  58. </view>
  59. </template>
  60. <script>
  61. var tim
  62. let page = 1;
  63. let app = getApp();
  64. var appEv = app.$vm.$options;
  65. import uniPopup from '@/components/uni-popup/uni-popup'
  66. import goodsLista from "@/components/goodsLista"
  67. import { get, post, u_post } from "@/request/api.js";
  68. export default {
  69. components: {
  70. uniPopup,
  71. goodsLista,
  72. },
  73. data() {
  74. return {
  75. integerInfo: {}, // 积分详情
  76. userInof: {}, // 用户详情
  77. timer: '00:00:00', // 倒计时
  78. goods: [], // 精品推荐
  79. haveGoods: false, // 是否有商品
  80. way_list: [], //兑换方式
  81. checked: false, //是否选中协议
  82. currrent: 0, // 选中的兑换方式
  83. pay_way: 0, //选中的支付方式
  84. isShow: false, // 是否显示现金支付
  85. goodsId: '', // 选中的商品Id
  86. shopInfo: {}, // 商户信息
  87. userinfo:undefined, //用户信息
  88. todaySign:0, //今日签到数
  89. totalSign:0, //累计签到数
  90. nextSign:0, //剩余签到时间 秒
  91. };
  92. },
  93. onShow() {
  94. this.timer = '00:00:00'
  95. this.userinfo = uni.getStorageSync("userinfo")
  96. this.loadData()
  97. this.goodsDay()
  98. },
  99. onHide() {
  100. clearInterval(tim)
  101. },
  102. methods: {
  103. loadData() {
  104. post("/user/sign").then(res => {
  105. if (res.code == 0) {
  106. // that.integerInfo = res.integerInfo
  107. // that.userInof = res.userInof
  108. this.todaySign = res.data.today_sign
  109. this.totalSign = res.data.total_sign
  110. this.nextSign = res.data.next_sign
  111. this.setTime()
  112. }
  113. })
  114. },
  115. // 距可以签到倒计时
  116. setTime() {
  117. var date;
  118. let timer = this.nextSign
  119. tim = setInterval(() => {
  120. if (timer >= 1) {
  121. timer--
  122. } else {
  123. clearInterval(tim)
  124. }
  125. let hour = parseInt(timer / 3600) > 9 ? parseInt(timer / 3600) : '0' + parseInt(timer / 3600)
  126. let min = parseInt(timer / 60 % 60) > 9 ? parseInt(timer / 60 % 60) : '0' + parseInt(timer / 60 % 60)
  127. let sec = parseInt(timer % 60) > 9 ? parseInt(timer % 60) : '0' + parseInt(timer % 60)
  128. date = hour + ':' + min + ':' + sec;
  129. // console.log(date);
  130. this.timer = date
  131. }, 999)
  132. },
  133. // 签到
  134. setSignIn() {
  135. post("user/doSign").then(res => {
  136. if (res.code === 0) {
  137. appEv.errTips(res.msg)
  138. this.loadData()
  139. } else {
  140. appEv.errTips(res.msg)
  141. }
  142. })
  143. },
  144. // 获取今日值得买
  145. goodsDay() {
  146. let that = this;
  147. let data = {
  148. page: page,
  149. type: 4
  150. }
  151. post("goods/goodsList", data).then(res => {
  152. if (res.code === 0) {
  153. let obj = res.data.data
  154. if(page == 1) that.goods = []
  155. if (obj.length > 0) {
  156. obj.forEach(e => {
  157. that.goods.push(e)
  158. });
  159. } else {
  160. if (page == 1) {
  161. that.haveGoods = true
  162. page = -1
  163. } else {
  164. page = -1
  165. appEv.errTips('暂无更多')
  166. }
  167. }
  168. } else {
  169. if (page == 1) {
  170. that.haveGoods = true
  171. page = -1
  172. } else {
  173. page = -1
  174. appEv.errTips('暂无更多')
  175. }
  176. }
  177. })
  178. },
  179. // 跳转到商品详情页
  180. NavToGoodsDetail(id, type) {
  181. this.goto("/pages/product/p_details", { id, type });
  182. },
  183. },
  184. //页面上拉触底事件的处理函数
  185. onReachBottom() {
  186. if (page != -1) {
  187. setTimeout(() => {
  188. ++page;
  189. this.goodsDay();
  190. }, 500);
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss" scoped>
  196. // 页面配置
  197. page {
  198. background: #f5f5f5;
  199. }
  200. .container {
  201. padding: var(--status-bar-height) 30rpx 30rpx;
  202. box-sizing: border-box;
  203. background: url('https://tea.soowin.com/mnt/image/sign_back.png');
  204. background-repeat: no-repeat;
  205. background-size: 100% 427rpx;
  206. }
  207. // 页面配置-end
  208. // 用户信息
  209. .userinfo {
  210. width: 100%;
  211. // margin-top: 24rpx;
  212. position: relative;
  213. }
  214. .user_img {
  215. width: 101.5rpx;
  216. height: 101.5rpx;
  217. margin-right: 20rpx;
  218. border-radius: 50%;
  219. }
  220. .level {
  221. background: rgba(0, 0, 0, .18);
  222. padding: 6rpx 24rpx;
  223. font-size: 24rpx;
  224. color: #fff;
  225. border-radius: 100rpx;
  226. }
  227. .user_name {
  228. font-size: 30rpx;
  229. color: #333;
  230. font-family: "SourceHanSansSC-Medium";
  231. font-weight: 500;
  232. margin-bottom: 18rpx;
  233. line-height: 1;
  234. }
  235. .record {
  236. width: 136rpx;
  237. height: 54rpx;
  238. background: rgba(0, 0, 0, .18);
  239. color: #fff;
  240. font-size: 24rpx;
  241. border-radius: 27rpx 0 0 27rpx;
  242. position: absolute;
  243. bottom: calc(50% - 27rpx);
  244. right: -30rpx;
  245. }
  246. // 用户信息-end
  247. // 签到信息
  248. .info {
  249. width: 100%;
  250. overflow: hidden;
  251. }
  252. .info_text {
  253. font-size: 24rpx;
  254. color: #404040;
  255. }
  256. .info_con {
  257. width: 185rpx;
  258. height: 185rpx;
  259. position: relative;
  260. }
  261. .info_img {
  262. width: 100%;
  263. height: 185rpx;
  264. animation: myfirst 1s infinite;
  265. }
  266. .info_texts {
  267. width: 100%;
  268. height: 100%;
  269. position: absolute;
  270. top: 0;
  271. left: 0;
  272. }
  273. .today_text {
  274. font-family: "SourceHanSansCN-Medium";
  275. font-size: 53rpx;
  276. color: #373737;
  277. }
  278. .info_texts text {
  279. width: 56rpx;
  280. text-align: justify;
  281. font-size: 28rpx;
  282. color: #12B381;
  283. }
  284. .sign_time text {
  285. width: 185rpx;
  286. overflow: hidden;
  287. font-size: 36rpx;
  288. color: #353535;
  289. font-family: "SourceHanSansCN-Bold";
  290. font-weight: bold;
  291. }
  292. .sign_info {
  293. width: 100%;
  294. overflow: hidden;
  295. background: #fff;
  296. border-radius: 16rpx;
  297. box-shadow: 0px 3px 0px 0px rgba(16, 178, 127, 0.36), 0px 6px 10px 0px rgba(17, 179, 129, 0.2);
  298. padding: 24rpx 40rpx;
  299. box-sizing: border-box;
  300. margin-top: 44rpx;
  301. }
  302. .g_color {
  303. color: #12B381;
  304. }
  305. .gr_color {
  306. color: #999 !important;
  307. }
  308. // 签到信息-end
  309. // 动画效果
  310. @keyframes myfirst {
  311. 0% {
  312. transform: rotate(0);
  313. }
  314. 10% {
  315. transform: rotate(-36deg);
  316. }
  317. 20% {
  318. transform: rotate(-72deg);
  319. }
  320. 30% {
  321. transform: rotate(-108deg);
  322. }
  323. 40% {
  324. transform: rotate(-144deg);
  325. }
  326. 50% {
  327. transform: rotate(-180deg);
  328. }
  329. 60% {
  330. transform: rotate(-216deg);
  331. }
  332. 70% {
  333. transform: rotate(-252deg);
  334. }
  335. 80% {
  336. transform: rotate(-288deg);
  337. }
  338. 90% {
  339. transform: rotate(-324deg);
  340. }
  341. 100% {
  342. transform: rotate(-360deg);
  343. }
  344. }
  345. // 动画效果-end
  346. // 积分兑好礼
  347. .more {
  348. font-size: 24rpx;
  349. color: #313131;
  350. }
  351. .inte_con {
  352. width: 100%;
  353. overflow: hidden;
  354. }
  355. .goods_price {
  356. font-size: 30rpx;
  357. color: #F15C21;
  358. }
  359. .inte_goods:nth-last-child(1) {
  360. margin-right: 0;
  361. }
  362. .goods_price text {
  363. font-size: 18rpx;
  364. color: #F15C21;
  365. }
  366. .more_img {
  367. width: 9rpx;
  368. height: 16rpx;
  369. margin-left: 10rpx;
  370. }
  371. .goods_img {
  372. width: 100%;
  373. height: 141rpx;
  374. margin-bottom: 16rpx;
  375. }
  376. .goods_name {
  377. width: 100%;
  378. overflow: hidden;
  379. color: #1D1D1D;
  380. font-size: 24rpx;
  381. }
  382. .inte_goods {
  383. width: calc((100% - 28rpx) / 3);
  384. margin-right: 14rpx;
  385. overflow: hidden;
  386. }
  387. .inte_title {
  388. font-size: 36rpx;
  389. color: #2A2A2A;
  390. font-family: "SourceHanSansSC-Bold";
  391. font-weight: bold;
  392. }
  393. .integral {
  394. width: 100%;
  395. overflow: hidden;
  396. background: #fff;
  397. padding: 30rpx;
  398. box-sizing: border-box;
  399. border-radius: 20rpx;
  400. }
  401. // 积分兑好礼-end
  402. // 精彩推荐
  403. .bou_head{
  404. width: 100%;
  405. height: 114rpx;
  406. margin-top: 50rpx;
  407. .bou_img{
  408. width: 89rpx;
  409. height: 30rpx;
  410. }
  411. .bou_title{
  412. font-size: 36rpx;
  413. color:#121212;
  414. font-family: "SourceHanSansSC-Bold";
  415. font-weight: bold;
  416. margin: 0 36rpx;
  417. }
  418. }
  419. .product-list {
  420. // padding: 0 20rpx;
  421. display: flex;
  422. width: 100%;
  423. flex-wrap: wrap;
  424. flex-direction: row;
  425. .product {
  426. // width: 50%;
  427. // padding: 20rpx 10rpx;
  428. // display: flex;
  429. // flex-direction: column;
  430. margin-bottom: 20rpx;
  431. width: 48.5%;
  432. padding-bottom: 6px;
  433. // border: 1px solid #eee;
  434. border-radius: 5px;
  435. box-shadow: 4rpx 4rpx 26rpx 2rpx rgba(17, 18, 29, 0.08);
  436. &:nth-child(2n){
  437. margin-left: 3%;
  438. }
  439. }
  440. .product-image {
  441. border-radius: 10rpx 10rpx 0 0;
  442. width: 100%;
  443. height: 260rpx;
  444. object-fit: cover;
  445. }
  446. .product-title {
  447. width: 100%;
  448. overflow: hidden;
  449. line-height: 1.5;
  450. font-size: 28rpx;
  451. color: #121212;
  452. }
  453. .product-price {
  454. color: #121212;
  455. font-size: 28rpx;
  456. position: relative;
  457. }
  458. .product-price-original {
  459. color: #18bb88;
  460. font-size: 32rpx;
  461. }
  462. .product-price-favour {
  463. color: #888888;
  464. text-decoration: line-through;
  465. margin-left: 10upx;
  466. }
  467. .product-tip {
  468. position: absolute;
  469. right: 10upx;
  470. background-color: #ff3333;
  471. color: #ffffff;
  472. padding: 0 10upx;
  473. border-radius: 5upx;
  474. }
  475. .product-unit {
  476. font-size: 24rpx;
  477. color: #18bb88;
  478. }
  479. .product-txt {
  480. font-size: 22rpx;
  481. color: #787878;
  482. }
  483. }
  484. </style>