shop.vue 7.4 KB

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