integralGoodsList.vue 6.7 KB

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