integralGoodsList.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <view class="content">
  3. <view class="cont-box">
  4. <u-sticky>
  5. <view class="top-box">
  6. <view class="my-integral">
  7. <view class="left">
  8. <view class="label">我的芳华币</view>
  9. <view style="margin-top: 30rpx;display: flex;align-items: baseline;">
  10. <view class="integral">{{integral}}</view>
  11. <view class="integralbtn" @click="goIntegral">获取芳华币</view>
  12. </view>
  13. </view>
  14. <view class="btn-box">
  15. <view class="btn" @click="navTo('/pages/user/integral/integralLogsList')">获得记录</view>
  16. <view class="btn" @click="navTo('/pages/user/integral/integralOrderList')">兑换记录</view>
  17. </view>
  18. </view>
  19. <view class="tabs" v-if="tabs.length>0">
  20. <u-tabs :current="tabIndex" :scrollable="true" :list="tabs" lineColor="#FF5C03"
  21. @change="tabChange">
  22. </u-tabs>
  23. </view>
  24. </view>
  25. </u-sticky>
  26. <mescroll-body bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  27. :down="downOption" :up="upOption">
  28. <view class="integral-box">
  29. <view class="item" @click="navTo('/pages/user/integral/integralGoodsDetails?goodsId='+item.goodsId)"
  30. v-for="(item,index) in dataList">
  31. <view class="top">
  32. <image :src="item.imgUrl"></image>
  33. </view>
  34. <view class="bottom">
  35. <view class="title ellipsis2">
  36. {{item.goodsName}}
  37. </view>
  38. <view class="price-box">
  39. <view class="price">{{item.integral}}芳华币</view>
  40. <view class="count">价值:{{item.otPrice.toFixed(2)}}元</view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </mescroll-body>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. // import {getDictByKey} from '@/api/common.js'
  51. // import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  52. // import {getIntegralGoodsList} from '@/api/integral.js'
  53. // import {getUserInfo} from '@/api/user'
  54. export default {
  55. mixins: [MescrollMixin],
  56. data() {
  57. return {
  58. integral: 0,
  59. type: "0",
  60. typeOptions: [],
  61. tabIndex: 0,
  62. tabs: [],
  63. mescroll: null,
  64. downOption: {
  65. use: true,
  66. auto: false,
  67. textInOffset: '下拉刷新', // 可选:下拉提示文字
  68. textOutOffset: '释放更新', // 可选:释放提示文字
  69. textLoading: '加载中...' // 可选:加载中提示文字
  70. },
  71. upOption: {
  72. onScroll: false,
  73. use: true, // 是否启用上拉加载; 默认true
  74. page: {
  75. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  76. size: 10 // 每页数据的数量,默认10
  77. },
  78. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  79. textNoMore: "已经到底了",
  80. empty: {
  81. icon: 'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  82. tip: '暂无数据'
  83. }
  84. },
  85. dataList: []
  86. }
  87. },
  88. onLoad() {
  89. this.getDictByKey("sys_integral_goods_type");
  90. this.getUserInfo();
  91. },
  92. methods: {
  93. getUserInfo() {
  94. getUserInfo().then(
  95. res => {
  96. if (res.code == 200) {
  97. if (res.user != null) {
  98. this.integral = res.user.integral;
  99. }
  100. } else {
  101. uni.showToast({
  102. icon: 'none',
  103. title: "请求失败",
  104. });
  105. }
  106. },
  107. rej => {}
  108. );
  109. },
  110. navTo(url) {
  111. uni.navigateTo({
  112. url: url
  113. })
  114. },
  115. goIntegral() {
  116. let pages = getCurrentPages();
  117. let url = pages[pages.length - 2];
  118. if (pages.length > 1 && url && url.route == 'pages/user/integral/points') {
  119. uni.navigateBack()
  120. } else {
  121. uni.navigateTo({
  122. url: '/pages/user/integral/points'
  123. })
  124. }
  125. },
  126. getDictByKey(key) {
  127. var data = {
  128. key: key
  129. }
  130. var that = this;
  131. getDictByKey(data).then(
  132. res => {
  133. if (res.code == 200) {
  134. this.typeOptions = res.data;
  135. this.typeOptions.forEach(function(item, index) {
  136. var data = {
  137. name: item.dictLabel
  138. };
  139. that.tabs.push(data);
  140. })
  141. if (this.tabs.length > 0) {
  142. this.tabIndex = 0
  143. }
  144. }
  145. },
  146. err => {}
  147. );
  148. },
  149. tabChange(item) {
  150. console.log(item.index)
  151. this.type = this.typeOptions[item.index].dictValue;
  152. this.mescroll.resetUpScroll()
  153. },
  154. mescrollInit(mescroll) {
  155. this.mescroll = mescroll;
  156. },
  157. /*下拉刷新的回调 */
  158. downCallback(mescroll) {
  159. mescroll.resetUpScroll()
  160. },
  161. upCallback(page) {
  162. //联网加载数据
  163. var that = this;
  164. var data = {
  165. pageNum: page.num,
  166. pageSize: page.size
  167. };
  168. if (this.type != null) {
  169. data.goodsType = this.type
  170. }
  171. getIntegralGoodsList(data).then(res => {
  172. if (res.code == 200) {
  173. //设置列表数据
  174. if (page.num == 1) {
  175. that.dataList = res.data.list;
  176. } else {
  177. that.dataList = that.dataList.concat(res.data.list);
  178. }
  179. that.mescroll.endBySize(res.data.list.length, res.data.total);
  180. } else {
  181. uni.showToast({
  182. icon: 'none',
  183. title: "请求失败",
  184. });
  185. that.dataList = null;
  186. that.mescroll.endErr();
  187. }
  188. });
  189. }
  190. }
  191. }
  192. </script>
  193. <style scoped lang="scss">
  194. page {
  195. height: 100%;
  196. background-color: #f5f5f5;
  197. }
  198. .content {
  199. height: 100%;
  200. .cont-box {
  201. .top-box {
  202. padding: 30rpx 30rpx 0 30rpx;
  203. width: 100%;
  204. background-color: #f5f5f5;
  205. .my-integral {
  206. height: 200rpx;
  207. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  208. background: linear-gradient(#FF5C03, #E2C99E);
  209. border-radius: 30rpx;
  210. display: flex;
  211. align-items: flex-start;
  212. justify-content: space-between;
  213. padding: 30rpx;
  214. .integralbtn {
  215. font-size: 24rpx;
  216. font-family: PingFang SC;
  217. color: #fff;
  218. margin-left: 16rpx;
  219. text-decoration: underline;
  220. }
  221. .btn {
  222. margin-bottom: 30rpx;
  223. background-color: #fff;
  224. border-radius: 30rpx;
  225. display: flex;
  226. align-items: center;
  227. justify-content: center;
  228. padding: 10rpx 15rpx;
  229. font-size: 20upx;
  230. font-family: PingFang SC;
  231. color: #FF5C03;
  232. }
  233. .left {
  234. .label {
  235. font-size: 28upx;
  236. font-family: PingFang SC;
  237. color: #fff;
  238. }
  239. .integral {
  240. font-weight: bold;
  241. font-size: 40upx;
  242. font-family: PingFang SC;
  243. color: #fff;
  244. }
  245. }
  246. .btn-box {
  247. display: flex;
  248. flex-direction: column;
  249. align-items: flex-start;
  250. justify-content: flex-start;
  251. }
  252. }
  253. .tabs {
  254. height: 88rpx;
  255. }
  256. }
  257. .integral-box {
  258. padding: 0 30rpx 30rpx 30rpx;
  259. display: flex;
  260. align-items: flex-start;
  261. justify-content: flex-start;
  262. flex-wrap: wrap;
  263. .item {
  264. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  265. background-color: #fff;
  266. width: calc(50% - 20rpx);
  267. border-radius: 15rpx;
  268. margin: 10rpx;
  269. display: flex;
  270. flex-direction: column;
  271. align-items: flex-start;
  272. justify-content: flex-start;
  273. &:last-child {}
  274. .top {
  275. width: 100%;
  276. height: 300rpx;
  277. image {
  278. border-radius: 15rpx 15rpx 0rpx 0rpx;
  279. width: 100%;
  280. height: 300rpx;
  281. }
  282. }
  283. .bottom {
  284. width: 100%;
  285. padding: 15rpx;
  286. .title {
  287. font-weight: bold;
  288. font-size: 28upx;
  289. font-family: PingFang SC;
  290. color: #111111;
  291. }
  292. .price-box {
  293. margin-top: 10rpx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: space-between;
  297. width: 100%;
  298. .price {
  299. padding: 5rpx 10rpx;
  300. background-color: #FF5C03;
  301. border-radius: 30rpx;
  302. font-size: 20upx;
  303. font-family: PingFang SC;
  304. color: #ffffff;
  305. }
  306. .count {
  307. font-size: 24upx;
  308. font-family: PingFang SC;
  309. color: #333333;
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. }
  317. </style>