shop.vue 7.4 KB

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