integralGoods.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view>
  3. <view class="top-box">
  4. <view class="my-integral" v-if="false">
  5. <view class="left">
  6. <view class="label">我的福币</view>
  7. <view style="margin-top: 30rpx;display: flex;align-items: baseline;">
  8. <view class="integral">{{integral}}</view>
  9. <view class="integralbtn" @click="goIntegral">获取福币</view>
  10. </view>
  11. </view>
  12. <view class="btn-box">
  13. <view class="btn" @click="navTo('/pages/user/integral/integralLogsList')">获得记录</view>
  14. <view class="btn" @click="navTo('/pages/user/integral/integralOrderList')">兑换记录</view>
  15. </view>
  16. </view>
  17. <!-- 搜索 -->
  18. <view class="search-box">
  19. <uni-search-bar class="search" bgColor="#eee" radius="34" v-model="keyword" placeholder="搜索商品" clearButton="auto" cancelButton="none"
  20. @confirm="refreshList">
  21. <template v-slot:searchIcon>
  22. <image src="@/static/image/hall/search_gray_icon.png" mode="aspectFill"></image>
  23. </template>
  24. </uni-search-bar>
  25. </view>
  26. <view class="tabs" v-if="tabs.length>0">
  27. <u-tabs :current="tabIndex" :scrollable="true" :list="tabs" lineColor="#2583EB" @change="tabChange">
  28. </u-tabs>
  29. </view>
  30. </view>
  31. <view class="integral-box">
  32. <view class="item" @click="navTo('/pages/user/integral/integralGoodsDetails?goodsId='+item.goodsId)"
  33. v-for="(item,index) in dataList">
  34. <view class="top">
  35. <image :src="item.imgUrl"></image>
  36. </view>
  37. <view class="bottom">
  38. <view class="title ellipsis2">
  39. {{item.goodsName}}
  40. </view>
  41. <view class="price-box">
  42. <view class="price" v-if="false">{{item.integral}}福币</view>
  43. <!-- 价值: -->
  44. <view class="count">{{item.otPrice.toFixed(2)}}元</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="x-ac" v-if="dataList&&dataList.length==0">
  50. <u-empty style="padding-top: 20px" mode="data"
  51. icon="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/cf4a86b913a04341bb44e34bb4d37aa2.png" text="暂无数据"></u-empty>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import { getDictByKey } from '@/api/common.js'
  57. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  58. import { getIntegralGoodsList } from '@/api/integral.js'
  59. import { getUserInfo } from '@/api/user'
  60. export default {
  61. mixins: [MescrollMixin],
  62. props:{
  63. i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  64. index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  65. type: Number,
  66. default(){
  67. return 0
  68. }
  69. },
  70. height: [Number,String] // mescroll的高度
  71. },
  72. data() {
  73. return {
  74. integral: 0,
  75. type: null,
  76. typeOptions: [],
  77. tabIndex: 0,
  78. tabs: [],
  79. mescroll: null,
  80. downOption: { //下拉刷新
  81. use: true,
  82. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  83. },
  84. upOption: {
  85. onScroll: false,
  86. use: true, // 是否启用上拉加载; 默认true
  87. page: {
  88. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  89. size: 10 // 每页数据的数量,默认10
  90. },
  91. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  92. textNoMore: "已经到底了",
  93. empty: {
  94. icon: 'https://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/cf4a86b913a04341bb44e34bb4d37aa2.png',
  95. tip: '暂无数据'
  96. }
  97. },
  98. dataList: [],
  99. total:0,
  100. pageNum: 1,
  101. pageSize: 10,
  102. keyword: "",
  103. }
  104. },
  105. mounted() {
  106. this.getDictByKey("sys_integral_goods_type");
  107. this.getUserInfo();
  108. this.refreshList()
  109. },
  110. methods: {
  111. initData() {
  112. this.getUserInfo();
  113. this.refreshList()
  114. },
  115. getUserInfo() {
  116. getUserInfo().then(
  117. res => {
  118. if (res.code == 200) {
  119. if (res.user != null) {
  120. this.integral = res.user.integral;
  121. }
  122. } else {
  123. uni.showToast({
  124. icon: 'none',
  125. title: "请求失败",
  126. });
  127. }
  128. },
  129. rej => {}
  130. );
  131. },
  132. navTo(url) {
  133. uni.navigateTo({
  134. url: url
  135. })
  136. },
  137. goIntegral() {
  138. let pages = getCurrentPages();
  139. let url = pages[pages.length - 2];
  140. if (pages.length > 1 && url && url.route == 'pages/user/integral/points') {
  141. uni.navigateBack()
  142. } else {
  143. uni.navigateTo({
  144. url: '/pages/user/integral/points'
  145. })
  146. }
  147. },
  148. getDictByKey(key) {
  149. var data = {
  150. key: key
  151. }
  152. var that = this;
  153. getDictByKey(data).then(
  154. res => {
  155. if (res.code == 200) {
  156. this.typeOptions = res.data;
  157. this.typeOptions.forEach(function(item, index) {
  158. var data = {
  159. name: item.dictLabel
  160. };
  161. that.tabs.push(data);
  162. })
  163. this.tabs.unshift({name: '全部'})
  164. if (this.tabs.length > 0) {
  165. this.tabIndex = 0
  166. }
  167. }
  168. },
  169. err => {}
  170. );
  171. },
  172. tabChange(item) {
  173. this.type = item.index == 0 ? null : this.typeOptions[item.index-1].dictValue;
  174. this.refreshList()
  175. },
  176. refreshList() {
  177. this.pageNum = 1
  178. this.isMore= true
  179. this.dataList = []
  180. this.getList()
  181. },
  182. // 滚动到底部
  183. scrolltolower() {
  184. if (this.isMore) {
  185. this.getList()
  186. }
  187. },
  188. getList() {
  189. //联网加载数据
  190. var that = this;
  191. var data = {
  192. pageNum: this.pageNum,
  193. pageSize: this.pageSize,
  194. keyword: this.keyword,
  195. };
  196. if (this.type != null) {
  197. data.goodsType = this.type
  198. }
  199. getIntegralGoodsList(data).then(res => {
  200. if (res.code == 200) {
  201. //设置列表数据
  202. let list = res.data.list && res.data.list.length > 0 ? res.data.list : []
  203. that.dataList = that.dataList.concat(list)
  204. that.total = res.data.total
  205. that.pageNum++
  206. if (that.dataList.length >= that.total) {
  207. that.isMore = false
  208. }
  209. } else {
  210. that.dataList = []
  211. }
  212. });
  213. }
  214. }
  215. }
  216. </script>
  217. <style scoped lang="scss">
  218. .top-box {
  219. padding: 0 30rpx 0 30rpx;
  220. width: 100%;
  221. .my-integral {
  222. height: 200rpx;
  223. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  224. background: linear-gradient(#2583EB, #E0F5FF);
  225. border-radius: 30rpx;
  226. display: flex;
  227. align-items: flex-start;
  228. justify-content: space-between;
  229. padding: 30rpx;
  230. .integralbtn {
  231. font-size: 24rpx;
  232. font-family: PingFang SC;
  233. color: #fff;
  234. margin-left: 16rpx;
  235. text-decoration: underline;
  236. }
  237. .btn {
  238. margin-bottom: 30rpx;
  239. background-color: #fff;
  240. border-radius: 30rpx;
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. padding: 10rpx 15rpx;
  245. font-size: 20upx;
  246. font-family: PingFang SC;
  247. color: #2583EB;
  248. }
  249. .left {
  250. .label {
  251. font-size: 28upx;
  252. font-family: PingFang SC;
  253. color: #fff;
  254. }
  255. .integral {
  256. font-weight: bold;
  257. font-size: 40upx;
  258. font-family: PingFang SC;
  259. color: #fff;
  260. }
  261. }
  262. .btn-box {
  263. display: flex;
  264. flex-direction: column;
  265. align-items: flex-start;
  266. justify-content: flex-start;
  267. }
  268. }
  269. .tabs {
  270. height: 88rpx;
  271. }
  272. }
  273. .integral-box {
  274. padding: 0 30rpx 30rpx 30rpx;
  275. display: flex;
  276. align-items: flex-start;
  277. justify-content: flex-start;
  278. flex-wrap: wrap;
  279. .item {
  280. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  281. background-color: #fff;
  282. width: calc(50% - 20rpx);
  283. border-radius: 15rpx;
  284. margin: 10rpx;
  285. display: flex;
  286. flex-direction: column;
  287. align-items: flex-start;
  288. justify-content: flex-start;
  289. &:last-child {}
  290. .top {
  291. width: 100%;
  292. height: 300rpx;
  293. image {
  294. border-radius: 15rpx 15rpx 0rpx 0rpx;
  295. width: 100%;
  296. height: 300rpx;
  297. }
  298. }
  299. .bottom {
  300. width: 100%;
  301. padding: 15rpx;
  302. .title {
  303. font-weight: bold;
  304. font-size: 28upx;
  305. font-family: PingFang SC;
  306. color: #111111;
  307. }
  308. .price-box {
  309. margin-top: 10rpx;
  310. display: flex;
  311. align-items: center;
  312. justify-content: space-between;
  313. width: 100%;
  314. .price {
  315. padding: 5rpx 10rpx;
  316. background-color: #2583EB;
  317. border-radius: 30rpx;
  318. font-size: 20upx;
  319. font-family: PingFang SC;
  320. color: #ffffff;
  321. }
  322. .count {
  323. font-size: 24upx;
  324. font-family: PingFang SC;
  325. color: #333333;
  326. }
  327. }
  328. }
  329. }
  330. }
  331. .search-box {
  332. display: flex;
  333. align-items: center;
  334. justify-content: space-between;
  335. padding-top: 22rpx;
  336. .search {
  337. padding: 0;
  338. flex: 1;
  339. image {
  340. width: 28rpx;
  341. height: 28rpx;
  342. padding-left: 16rpx;
  343. }
  344. }
  345. }
  346. </style>