integralGoodsList.vue 7.3 KB

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