index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view>
  3. <!--pages/integralshop/integralshop.wxml-->
  4. <view class="banner">
  5. <!-- <image src="/integralshop/static/integralshop/images/integral_bg.png" role="img"></image> -->
  6. </view>
  7. <view class="top ">
  8. <view class="dflex integral">
  9. <view class="flex" @tap="goDetailed">
  10. <view class="txt">{{userIntegral}}</view>
  11. <view class="my dflex">积分余额</view>
  12. <!-- <view class="rule dflex" @tap="goRule">积分规则<image src="/static/integralshop/images/you_h.png"></image>
  13. </view> -->
  14. </view>
  15. <view class="rule dflex" @tap="isSign==0||sign==1?'':signFun()">
  16. <image src="../static/integralShop/images/qdico.png"></image>{{isSign==0||sign==1?'已签到':'签到'}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="nav">
  21. <view class="item dflex">
  22. <view @tap="goRule" class="dflex grule">
  23. <image src="/integralshop/static/integralshop/images/sign.png" class="more"></image>获取积分
  24. </view>
  25. <view @tap="goDetailed" class="dflex">
  26. <image src="/integralshop/static/integralshop/images/detailed.png" class="detailed"></image>积分明细
  27. </view>
  28. <!-- <view>
  29. <image src="/integralshop/images/card.png"></image>卡券兑换
  30. </view> -->
  31. </view>
  32. </view>
  33. <view class="cont">
  34. <view class="pop">
  35. <view :class="'filter dflex bgfff ' + (isShow?'filter1':'')">
  36. <view :class="'li ' + (active=='default'?'active':'')" @tap="ss" data-v="default">默认</view>
  37. <view :class="'li ' + (active=='stock'?'active':'')" @tap="ss" data-v="stock">销量
  38. </view>
  39. <view :class="'li ' + (active=='fraction'?'active':'')" @tap="ss" data-v="fraction">积分<image
  40. :src="isShow?'/integralshop/static/integralshop/images/integral_up.png':'/integralshop/static/integralshop/images/integral_down.png'"
  41. class="updown">
  42. </image>
  43. </view>
  44. </view>
  45. <view class="item" v-if="isShow">
  46. <view :class="'brbtm dflex ' + (sort=='gtIntegral'?'active':'')" @tap="fraction"
  47. data-v="gtIntegral">积分降序<image src="/integralshop/static/integralshop/images/integral_gou.png"
  48. v-if="sort=='gtIntegral'"></image>
  49. </view>
  50. <view :class="'dflex ' + (sort=='ltIntegral'?'active':'')" @tap="fraction" data-v="ltIntegral">积分升序
  51. <image src="/integralshop/static/integralshop/images/integral_gou.png"
  52. v-if="sort=='ltIntegral'"></image>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="mask" @tap="eliminate" v-if="isShow"></view>
  57. <view class="pintuan pdlr20">
  58. <view v-for="(item, index) in pageList" :key="index" class="li" @tap="goproDetail" :data-id="item.id"
  59. :data-merchant="merchant.type==5?merchant.merchantDTO.id:merchant.id"
  60. :data-shopId="merchant.type==5?merchant.id:''">
  61. <view class="dflex">
  62. <view class="pinimgs">
  63. <image :src="item.pic" mode="aspectFit" class="pinimg"></image>
  64. </view>
  65. <view class="pininfo flex">
  66. <view class="proname">
  67. {{item.title}}
  68. </view>
  69. <view class="operate">
  70. <view class="introduce">
  71. {{item.brief}}
  72. </view>
  73. </view>
  74. <view class="price dflex">
  75. <view class="dflex">
  76. <text class="num">{{item.integral}}</text><text class="money">积分</text>
  77. <view><text class="prc">+¥{{item.actualPrice }}</text></view>
  78. </view>
  79. <view class="btn baglig">兑换</view>
  80. <!-- <view class="btn file" >积分不足</view> -->
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="nodata" v-if="ishow">
  88. <image :src="picUrlss+'empty_sp.png'"></image>
  89. <text>暂无商品</text>
  90. </view>
  91. <view class="nomore dflex">亲,没有更多了</view>
  92. <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 115) + 'rpx'"></view>
  93. <foot product-type="2" :isUpdate="isUpdate"></foot>
  94. </view>
  95. </template>
  96. <script>
  97. // pages/integralshop/integralshop.js
  98. const app = getApp();
  99. const req = require("../../utils/request.js");
  100. import foot from "../components/integral-nav/index";
  101. export default {
  102. data() {
  103. return {
  104. picUrlss: req.public.picUrls,
  105. page: 1,
  106. isLoad: true,
  107. isShow: false,
  108. sort: '',
  109. active: 'default',
  110. isUpdate: false // 是否更新消息
  111. ,
  112. merchant: "",
  113. isSign: "",
  114. hasmore: false,
  115. pageList: "",
  116. ishow: false,
  117. sign: 0,
  118. hasemore: false
  119. };
  120. },
  121. components: {
  122. foot
  123. },
  124. props: {},
  125. /**
  126. * 生命周期函数--监听页面加载
  127. */
  128. onLoad: function(options) {
  129. // this.getProct()
  130. // this.getMerchant()
  131. // this.setData({merchant:req.getStorage("MERCHANT")})
  132. this.setData({
  133. merchant: req.getStorage("defaultMerchant")
  134. });
  135. },
  136. /**
  137. * 生命周期函数--监听页面显示
  138. */
  139. onShow: function() {
  140. // #ifdef MP-WEIXIN
  141. uni.hideHomeButton();
  142. // #endif
  143. this.getProct();
  144. this.isSignFun();
  145. this.getIntegral();
  146. this.setData({
  147. isUpdate: !this.isUpdate
  148. });
  149. },
  150. /**
  151. * 生命周期函数--监听页面隐藏
  152. */
  153. onHide: function() {
  154. this.isLoad = true;
  155. },
  156. /**
  157. * 生命周期函数--监听页面卸载
  158. */
  159. onUnload: function() {},
  160. /**
  161. * 页面相关事件处理函数--监听用户下拉动作
  162. */
  163. onPullDownRefresh: function() {},
  164. /**
  165. * 页面上拉触底事件的处理函数
  166. */
  167. onReachBottom: function() {
  168. this.page++;
  169. this.getProct();
  170. }
  171. /**
  172. * 用户点击右上角分享
  173. */
  174. // onShareAppMessage: function () {
  175. // }
  176. ,
  177. methods: {
  178. // 是否签到{}
  179. isSignFun() {
  180. req.getRequest('/api/integral/isSign', {}, res => {
  181. this.setData({
  182. isSign: res
  183. });
  184. });
  185. },
  186. // 获取用户积分
  187. getIntegral() {
  188. req.getRequest('/api/integral/totalIntegral', {}, res => {
  189. // console.log(res);
  190. this.setData(res);
  191. });
  192. },
  193. getMerchant() {
  194. // let merchant = req.getStorage("MERCHANT");
  195. req.getRequest('/api/merchant/getMerchantList', {}, res => {
  196. res = res.filter(it => it.isDefault == 1);
  197. var timestamp = Date.parse(new Date());
  198. res[0].time = timestamp + 1 * 60 * 1000
  199. req.setStorage('MERCHANT', res[0]);
  200. this.setData({
  201. merchant: res[0]
  202. });
  203. });
  204. },
  205. // 获取产品列表
  206. getProct() {
  207. let isShowLoading = false;
  208. if (this.page == 1 && !isShowLoading) {
  209. req.loadIng('加载中');
  210. isShowLoading = true;
  211. }
  212. let that = this;
  213. if (!that.isLoad) return false;
  214. that.isLoad = false;
  215. let from = {
  216. page: this.page,
  217. limit: 10,
  218. mode: 2,
  219. sort: this.sort
  220. };
  221. req.getRequest('/api/product/list', from, data => {
  222. if (data && data.length >= 10) that.isLoad = true;
  223. if (that.page > 1) data = that.pageList.concat(data);
  224. if (!data || data.length < 10) {
  225. that.setData({
  226. hasmore: true
  227. });
  228. }
  229. that.setData({
  230. pageList: data
  231. });
  232. // console.log(data);
  233. if (data.length <= 0) {
  234. that.setData({
  235. ishow: true
  236. });
  237. } else {
  238. that.setData({
  239. ishow: false
  240. });
  241. }
  242. if (isShowLoading) {
  243. uni.hideLoading();
  244. isShowLoading = false;
  245. }
  246. });
  247. },
  248. // 商品详情
  249. goproDetail(e) {
  250. var id = e.currentTarget.dataset.id;
  251. let merchantId = e.currentTarget.dataset.merchant;
  252. let shopId = e.currentTarget.dataset.shopid;
  253. if (!shopId) {
  254. if (!merchantId) {
  255. uni.navigateTo({
  256. url: '/integralshop/detail/detail?id=' + id
  257. });
  258. } else {
  259. uni.navigateTo({
  260. url: '/integralshop/detail/detail?id=' + id + '&merchantId=' + merchantId
  261. });
  262. }
  263. } else {
  264. uni.navigateTo({
  265. url: '/integralshop/detail/detail?id=' + id + '&merchantId=' + merchantId + '&shopId=' +
  266. shopId
  267. });
  268. } // wx.navigateTo({
  269. // url: '/integralshop/detail/detail?id='+id,
  270. // })
  271. },
  272. // 积分规则
  273. goRule() {
  274. uni.navigateTo({
  275. url: "/integralshop/integralRule/index"
  276. });
  277. },
  278. // 签到
  279. signFun() {
  280. req.postRequest('/api/integral/sign', {}, data => {
  281. if (data) {
  282. req.msg('连续签到' + data.continuityDay + '天' + ',获得' + data.IntegralChange + '积分');
  283. this.setData({
  284. sign: 1
  285. });
  286. this.getIntegral();
  287. }
  288. });
  289. },
  290. // 积分明细
  291. goDetailed() {
  292. uni.navigateTo({
  293. url: "/integralshop/integralDetailed/index"
  294. });
  295. },
  296. // 分数排序
  297. fraction(e) {
  298. var dt = e.currentTarget.dataset;
  299. this.isLoad = true;
  300. this.setData({
  301. isShow: false
  302. });
  303. this.refresh(dt.v);
  304. },
  305. ss(e) {
  306. var dt = e.currentTarget.dataset;
  307. if (dt.v == 'fraction') {
  308. this.setData({
  309. isShow: true
  310. });
  311. } else {
  312. this.setData({
  313. isShow: false
  314. });
  315. }
  316. if (dt.v == 'default') {
  317. this.isLoad = true;
  318. this.refresh(dt.v);
  319. }
  320. if (dt.v == 'stock') {
  321. this.isLoad = true;
  322. this.refresh(dt.v);
  323. } // this.data.isLoad = true;
  324. // this.refresh(dt.v);
  325. this.setData({
  326. active: dt.v
  327. });
  328. },
  329. refresh(s, t) {
  330. this.setData({
  331. hasemore: true,
  332. sort: s
  333. });
  334. this.page = 1;
  335. this.getProct();
  336. },
  337. eliminate() {
  338. this.setData({
  339. isShow: false
  340. });
  341. }
  342. }
  343. };
  344. </script>
  345. <style>
  346. @import "./index.css";
  347. </style>