shop.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <view :style="vuex_skin" style="width: 100vw;overflow: hidden;">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <u-navbar title-color="#fff" z-index="90" :border-bottom="false" :is-back="false" title="积分换礼"
  5. :background="{'backgroundColor': vuex_theme.shopBg}"></u-navbar>
  6. <!-- #endif -->
  7. <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  8. <view class="bg-card">
  9. <view class="info" style="display: flex;justify-content: space-between;">
  10. <view class="flex" v-if="vuex_userId">
  11. <image style="width: 90rpx;height: 90rpx;border-radius: 50%;" :src="avatar">
  12. </image>
  13. <view class="center data">
  14. <text style="color: #FFD7D9;">我的积分:</text>
  15. <text class="text-bold text-xxl">{{userData.userPufaPoint || 0}}</text>
  16. </view>
  17. </view>
  18. <view class="flex" v-else @click="showLogin">
  19. <image style="width: 90rpx;height: 90rpx;border-radius: 50%;" src="/static/icon/unlogin.png">
  20. </image>
  21. <view class="center data">
  22. <text style="color: #FFFFFF;font-weight: 800;">点击授权登录</text>
  23. </view>
  24. </view>
  25. <view class="center" style="margin-right: -30rpx;">
  26. <view class="cu-btn round sm rule"
  27. @click="$jump('/pages/introduce/notice?title=积分规则')">
  28. 积分兑换规则
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="swiper">
  34. <u-swiper :list="swiperList" name="url" mode="rect" border-radius="12" height="270"></u-swiper>
  35. </view>
  36. <view class="recommend-info">
  37. <view class="goods-list">
  38. <navigator hover-class="none" :url="'detail?id='+item.id" class="list" v-for="(item,index) in list"
  39. :key="index">
  40. <view class="pictrue">
  41. <image :src="item.imgUrl"></image>
  42. </view>
  43. <view class="title-tag" style="text-align: center;font-weight: 800;">
  44. <text class="text-cut-1">{{item.name}}</text>
  45. </view>
  46. <view class="price-info">
  47. <view class="user-price">
  48. <text class="min">¥</text>
  49. <text class="max">{{item.point}}积分</text>
  50. </view>
  51. </view>
  52. <view class="bottom padding-top-20">
  53. <button class="cu-btn round text-white bg-base"
  54. style="width: 140upx;height: 50upx;">兑换</button>
  55. </view>
  56. </navigator>
  57. </view>
  58. </view>
  59. </mescroll-body>
  60. <login ref="login" @signIn="signIn" @phoneSuccess="phoneSuccess"></login>
  61. <u-tabbar :bg-color="tabbar.bgColor" :icon-size="tabbar.iconSize" :height="100" :border-top="tabbar.borderTop"
  62. :inactive-color="tabbar.inactiveColor" :active-color="tabbar.activeColor" :list="tabbar.list">
  63. </u-tabbar>
  64. </view>
  65. </template>
  66. <script>
  67. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  68. import {tabbar} from "@/assets/http/tabbar.js"
  69. export default {
  70. mixins: [MescrollMixin],
  71. data() {
  72. return {
  73. //tabbar
  74. tabbar: {},
  75. swiperList: [],
  76. downOption: {
  77. auto: false
  78. },
  79. upOption:{
  80. auto:false
  81. },
  82. avatar: '',
  83. userData: {},
  84. list: []
  85. }
  86. },
  87. onShow() {
  88. this.init()
  89. },
  90. async onLoad() {
  91. //加载底部导航栏
  92. this.fetchTabbar()
  93. //获取轮播图
  94. this.fetchSwiperList()
  95. //加载积分商城
  96. this.fetchGoods()
  97. },
  98. methods: {
  99. fetchGoods(){
  100. // #ifdef MP-WEIXIN
  101. this.mescroll.resetUpScroll();
  102. // #endif
  103. // #ifdef H5
  104. setTimeout(()=>{
  105. this.mescroll.resetUpScroll();
  106. },50)
  107. // #endif
  108. },
  109. async fetchTabbar() {
  110. this.tabbar = tabbar
  111. if (this.vuex_theme.bgColor) {
  112. this.tabbar.activeColor = this.vuex_theme.bgColor
  113. }else{
  114. this.tabbar.activeColor = this.$config.themeRed.theme.bgColor
  115. }
  116. },
  117. async fetchSwiperList() {
  118. try {
  119. let {
  120. POINT_GOODS_SETTING
  121. } = (await this.$api.platform.getPlatformParams({
  122. keys: 'POINT_GOODS_SETTING'
  123. })).data.data;
  124. this.swiperList = JSON.parse(POINT_GOODS_SETTING).indexImageList
  125. } catch (e) {
  126. console.log(e);
  127. }
  128. },
  129. init() {
  130. this.avatar = this.$cache.get('userInfo').avatar
  131. this.fetchUserInfo()
  132. },
  133. fetchUserInfo() {
  134. if (!this.vuex_phone) {
  135. return
  136. }
  137. let params = {
  138. phone: this.vuex_phone
  139. }
  140. this.$api.loginUser.userHeatValueAndPufaPoint(params).then(res => {
  141. this.userData = res.data.data
  142. })
  143. },
  144. downCallback() {
  145. setTimeout(() => {
  146. this.fetchSwiperList()
  147. this.mescroll.resetUpScroll();
  148. }, 800)
  149. },
  150. upCallback(mescroll) {
  151. try {
  152. let params = {
  153. current: mescroll.num,
  154. size: mescroll.size,
  155. }
  156. this.$api.pointgoods.list(params).then(res => {
  157. let data = res.data.data.records
  158. let total = res.data.data.total
  159. mescroll.endBySize(data.length, total);
  160. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  161. this.list = this.list.concat(data); //追加新数据
  162. })
  163. } catch (e) {
  164. console.error(e);
  165. this.mescroll.endErr()
  166. }
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .rule {
  173. background-color: var(--shopRule);
  174. color: #FFFFFF;
  175. padding: 20rpx 40rpx 20rpx 30rpx;
  176. }
  177. .bg-card {
  178. // position: relative;
  179. width: 100vw;
  180. height: 260rpx;
  181. background-color: var(--shopBg);
  182. border-radius: 0 0 10% 10%;
  183. .info {
  184. display: flex;
  185. padding: 30rpx 0rpx 0rpx 40rpx;
  186. .data {
  187. color: #FFFFFF;
  188. margin-left: 10rpx;
  189. }
  190. }
  191. }
  192. .swiper {
  193. margin-top: -120rpx;
  194. padding: 0 20rpx;
  195. }
  196. /* 为你推荐 */
  197. .recommend-info {
  198. padding-top: 30rpx;
  199. width: 100%;
  200. border-radius: 20rpx;
  201. .recommend-title {
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. width: 100%;
  206. height: 100rpx;
  207. .title {
  208. display: flex;
  209. align-items: center;
  210. image {
  211. width: 416rpx;
  212. height: 40rpx;
  213. }
  214. }
  215. }
  216. .goods-list {
  217. display: flex;
  218. flex-wrap: wrap;
  219. justify-content: space-between;
  220. padding: 0 20rpx;
  221. .list {
  222. width: 49%;
  223. height: 550rpx;
  224. margin-bottom: 20rpx;
  225. background-color: #FFFFFF;
  226. border-radius: 12rpx;
  227. overflow: hidden;
  228. .pictrue {
  229. display: flex;
  230. justify-content: center;
  231. width: 100%;
  232. image {
  233. width: 100%;
  234. height: 340rpx;
  235. }
  236. }
  237. .title-tag {
  238. // display: flex;
  239. height: 70rpx;
  240. padding: 20rpx;
  241. }
  242. .price-info {
  243. display: flex;
  244. flex-wrap: wrap;
  245. align-items: center;
  246. justify-content: center;
  247. padding: 0 20rpx;
  248. height: 50rpx;
  249. .user-price {
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. text {
  254. color: #e72226;
  255. }
  256. .min {
  257. font-size: 24rpx;
  258. }
  259. .max {
  260. font-size: 32rpx;
  261. }
  262. }
  263. .vip-price {
  264. padding-left: 20rpx;
  265. display: flex;
  266. align-items: center;
  267. image {
  268. width: 26rpx;
  269. height: 26rpx;
  270. margin-right: 10rpx;
  271. }
  272. text {
  273. text-decoration: line-through;
  274. color: #8c8c8c;
  275. font-size: 24rpx;
  276. }
  277. }
  278. }
  279. .bottom {
  280. margin: 10rpx 0;
  281. display: flex;
  282. justify-content: center;
  283. align-items: flex-end;
  284. }
  285. }
  286. }
  287. }
  288. </style>
  289. <!-- <template>
  290. <view :style="vuex_skin">
  291. <mescroll-body-diy ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback"
  292. @up="upCallback">
  293. </mescroll-body-diy>
  294. </view>
  295. </template>
  296. <script>
  297. import MescrollBodyDiy from "@/uni_modules/mescroll-uni/components/mescroll-diy/xinlang/mescroll-body.vue";
  298. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  299. export default {
  300. mixins: [MescrollMixin],
  301. data() {
  302. return {
  303. downOption: {
  304. auto: false
  305. },
  306. list: [],
  307. }
  308. },
  309. methods: {
  310. downCallback() {
  311. setTimeout(() => {
  312. this.mescroll.resetUpScroll();
  313. }, 1000)
  314. },
  315. upCallback(mescroll) {
  316. try {
  317. let params = {
  318. current: mescroll.num,
  319. size: mescroll.size,
  320. }
  321. this.$api.pointgoods.list(params).then(res => {
  322. let data = res.data.data.records
  323. let total = res.data.data.total
  324. mescroll.endBySize(data.length, total);
  325. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  326. this.list = this.list.concat(data); //追加新数据
  327. })
  328. } catch (e) {
  329. console.error(e);
  330. this.mescroll.endErr()
  331. }
  332. }
  333. }
  334. }
  335. </script>
  336. -->