integralGoodsList.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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="loginNavTo('/pages_user/integralLogsList')">获得记录</view>
  12. <view class="btn" @click="loginNavTo('/pages_user/integralOrderList')">兑换记录</view>
  13. </view>
  14. </view>
  15. <view class="search-cont">
  16. <view class="inner">
  17. <image class="icon-search" src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_search.png" mode=""></image>
  18. <input type="text" v-model="keyword" placeholder="搜索商品" confirm-type="search" @confirm="doSearch" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  19. </view>
  20. </view>
  21. <view class="tabs" v-if="tabs.length>0">
  22. <u-tabs
  23. :current="tabIndex"
  24. :scrollable="true"
  25. :list="tabs"
  26. lineColor="#2583EB"
  27. @change="tabChange">
  28. </u-tabs>
  29. </view>
  30. </view>
  31. <mescroll-body :top="top+'px'" bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  32. <view class="integral-box" >
  33. <view class="item" @click="navTo('/pages_user/integralGoodsDetails?goodsId='+item.goodsId)" 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">{{item.integral}}积分</view>
  43. <view class="count">价值:{{item.otPrice.toFixed(2)}}元</view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </mescroll-body>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import {getDictByKey} from '@/api/common.js'
  54. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  55. import {getIntegralGoodsList} from '@/api/integral.js'
  56. import {getUserInfo} from '@/api/user'
  57. export default {
  58. mixins: [MescrollMixin],
  59. data() {
  60. return {
  61. integral:0,
  62. type: null,
  63. typeOptions:[],
  64. tabIndex:0,
  65. tabs: [],
  66. mescroll:null,
  67. downOption: { //下拉刷新
  68. use:true,
  69. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  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://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',
  82. tip: '暂无数据'
  83. }
  84. },
  85. dataList: [],
  86. keyword:"",
  87. top: uni.upx2px(432)
  88. }
  89. },
  90. onLoad() {
  91. this.getDictByKey("sys_integral_goods_type");
  92. this.$isLogin().then(
  93. res => {
  94. if(res){
  95. this.getUserInfo();
  96. }
  97. }
  98. );
  99. },
  100. onReady() {
  101. this.getTop()
  102. },
  103. methods: {
  104. getTop() {
  105. const query = uni.createSelectorQuery().in(this);
  106. query
  107. .select(".top-box")
  108. .boundingClientRect((data) => {
  109. if(data) {
  110. this.top = data.height + uni.upx2px(88)
  111. }
  112. })
  113. .exec();
  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. loginNavTo(url){
  133. this.$isLogin().then(
  134. res => {
  135. if(res){
  136. uni.navigateTo({
  137. url: url
  138. })
  139. }
  140. else{
  141. uni.navigateTo({
  142. url:'/pages/auth/login'
  143. })
  144. }
  145. }
  146. );
  147. },
  148. navTo(url) {
  149. uni.navigateTo({
  150. url: url
  151. })
  152. },
  153. getDictByKey(key){
  154. var data={key:key}
  155. var that=this;
  156. getDictByKey(data).then(
  157. res => {
  158. if(res.code==200){
  159. this.typeOptions=res.data;
  160. this.typeOptions.forEach(function(item,index){
  161. var data={name:item.dictLabel};
  162. that.tabs.push(data);
  163. })
  164. this.tabs.unshift({name: '全部'})
  165. if(this.tabs.length>0){
  166. this.tabIndex=0
  167. }
  168. }
  169. },
  170. err => {
  171. }
  172. );
  173. },
  174. doSearch() {
  175. this.tabIndex=0
  176. this.type = null;
  177. this.mescroll.resetUpScroll()
  178. },
  179. tabChange(item){
  180. this.type = item.index == 0 ? null : this.typeOptions[item.index-1].dictValue;
  181. this.mescroll.resetUpScroll()
  182. },
  183. mescrollInit(mescroll) {
  184. this.mescroll = mescroll;
  185. },
  186. /*下拉刷新的回调 */
  187. downCallback(mescroll) {
  188. mescroll.resetUpScroll()
  189. },
  190. upCallback(page) {
  191. //联网加载数据
  192. var that = this;
  193. var data = {
  194. pageNum: page.num,
  195. pageSize: page.size,
  196. keyword: this.keyword
  197. };
  198. if(this.type!=null){
  199. data.goodsType=this.type
  200. }
  201. getIntegralGoodsList(data).then(res => {
  202. if(res.code==200){
  203. //设置列表数据
  204. if (page.num == 1) {
  205. that.dataList = res.data.list;
  206. } else {
  207. that.dataList = that.dataList.concat(res.data.list);
  208. }
  209. that.mescroll.endBySize(res.data.list.length, res.data.total);
  210. }else{
  211. uni.showToast({
  212. icon:'none',
  213. title: "请求失败",
  214. });
  215. that.dataList = null;
  216. that.mescroll.endErr();
  217. }
  218. });
  219. }
  220. }
  221. }
  222. </script>
  223. <style scoped lang="scss">
  224. page{
  225. height: 100%;
  226. background-color: #f5f5f5;
  227. }
  228. .search-cont{
  229. height: 88upx;
  230. width: 100%;
  231. display: flex;
  232. align-items: flex-end;
  233. .inner{
  234. box-sizing: border-box;
  235. width: 100%;
  236. height: 72upx;
  237. background: #fff;
  238. border-radius: 36upx;
  239. display: flex;
  240. align-items: center;
  241. padding: 0 30upx;
  242. .icon-search{
  243. width: 28upx;
  244. height: 28upx;
  245. margin-right: 20upx;
  246. }
  247. input{
  248. height: 60upx;
  249. line-height: 60upx;
  250. flex: 1;
  251. }
  252. }
  253. }
  254. .content{
  255. height: 100%;
  256. .cont-box{
  257. .top-box{
  258. z-index: 999;
  259. padding: 30rpx 30rpx 0 30rpx;
  260. width: 100%;
  261. position: fixed;
  262. top: 0rpx;
  263. left: 0rpx;
  264. background-color: #f5f5f5;
  265. .my-integral{
  266. height: 200rpx;
  267. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  268. background: linear-gradient(#2583EB, #2EDAD4);
  269. border-radius: 30rpx;
  270. display: flex;
  271. align-items: flex-start;
  272. justify-content: space-between;
  273. padding: 30rpx;
  274. .left{
  275. .label{
  276. font-size: 28upx;
  277. font-family: PingFang SC;
  278. color: #fff;
  279. }
  280. .integral{
  281. margin-top: 30rpx;
  282. font-weight: bold;
  283. font-size: 40upx;
  284. font-family: PingFang SC;
  285. color: #fff;
  286. }
  287. }
  288. .btn-box{
  289. display: flex;
  290. flex-direction: column;
  291. align-items: flex-start;
  292. justify-content: flex-start;
  293. .btn{
  294. margin-bottom: 30rpx;
  295. background-color: #fff;
  296. border-radius: 30rpx;
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. padding: 10rpx 15rpx;
  301. font-size: 20upx;
  302. font-family: PingFang SC;
  303. color: #2583EB;
  304. }
  305. }
  306. }
  307. .tabs{
  308. height: 88rpx;
  309. }
  310. }
  311. .integral-box{
  312. padding: 30rpx;
  313. display: flex;
  314. align-items: flex-start;
  315. justify-content: flex-start;
  316. flex-wrap: wrap;
  317. .item{
  318. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  319. background-color: #fff;
  320. width: calc(50% - 20rpx);
  321. border-radius: 15rpx;
  322. margin: 10rpx;
  323. display: flex;
  324. flex-direction: column;
  325. align-items: flex-start;
  326. justify-content: flex-start;
  327. &:last-child{
  328. }
  329. .top{
  330. width:100%;
  331. height:300rpx;
  332. image{
  333. border-radius: 15rpx 15rpx 0rpx 0rpx;
  334. width:100%;
  335. height:300rpx;
  336. }
  337. }
  338. .bottom{
  339. width: 100%;
  340. padding: 15rpx;
  341. .title{
  342. font-weight: bold;
  343. font-size: 28upx;
  344. font-family: PingFang SC;
  345. color: #111111;
  346. }
  347. .price-box{
  348. margin-top: 10rpx;
  349. display: flex;
  350. align-items: center;
  351. justify-content: space-between;
  352. width: 100%;
  353. .price{
  354. padding: 5rpx 10rpx;
  355. background-color: #2583EB;
  356. border-radius: 30rpx;
  357. font-size: 20upx;
  358. font-family: PingFang SC;
  359. color: #ffffff;
  360. }
  361. .count{
  362. font-size: 24upx;
  363. font-family: PingFang SC;
  364. color: #333333;
  365. }
  366. }
  367. }
  368. }
  369. }
  370. }
  371. }
  372. </style>