exchange.vue 9.4 KB

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