index.vue 12 KB

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