shop.vue 7.3 KB

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