index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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="../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. this.getProct();
  141. this.isSignFun();
  142. this.getIntegral();
  143. this.setData({
  144. isUpdate: !this.isUpdate
  145. });
  146. },
  147. /**
  148. * 生命周期函数--监听页面隐藏
  149. */
  150. onHide: function() {
  151. this.isLoad = true;
  152. },
  153. /**
  154. * 生命周期函数--监听页面卸载
  155. */
  156. onUnload: function() {},
  157. /**
  158. * 页面相关事件处理函数--监听用户下拉动作
  159. */
  160. onPullDownRefresh: function() {},
  161. /**
  162. * 页面上拉触底事件的处理函数
  163. */
  164. onReachBottom: function() {
  165. this.page++;
  166. this.getProct();
  167. }
  168. /**
  169. * 用户点击右上角分享
  170. */
  171. // onShareAppMessage: function () {
  172. // }
  173. ,
  174. methods: {
  175. // 是否签到{}
  176. isSignFun() {
  177. req.getRequest('/api/integral/isSign', {}, res => {
  178. this.setData({
  179. isSign: res
  180. });
  181. });
  182. },
  183. // 获取用户积分
  184. getIntegral() {
  185. req.getRequest('/api/integral/totalIntegral', {}, res => {
  186. // console.log(res);
  187. this.setData(res);
  188. });
  189. },
  190. getMerchant() {
  191. // let merchant = req.getStorage("MERCHANT");
  192. req.getRequest('/api/merchant/getMerchantList', {}, res => {
  193. res = res.filter(it => it.isDefault == 1);
  194. var timestamp = Date.parse(new Date());
  195. res[0].time = timestamp + 1 * 60 * 1000
  196. req.setStorage('MERCHANT', res[0]);
  197. this.setData({
  198. merchant: res[0]
  199. });
  200. });
  201. },
  202. // 获取产品列表
  203. getProct() {
  204. let isShowLoading = false;
  205. if (this.page == 1 && !isShowLoading) {
  206. req.loadIng('加载中');
  207. isShowLoading = true;
  208. }
  209. let that = this;
  210. if (!that.isLoad) return false;
  211. that.isLoad = false;
  212. let from = {
  213. page: this.page,
  214. limit: 10,
  215. mode: 2,
  216. sort: this.sort
  217. };
  218. req.getRequest('/api/product/list', from, data => {
  219. if (data && data.length >= 10) that.isLoad = true;
  220. if (that.page > 1) data = that.pageList.concat(data);
  221. if (!data || data.length < 10) {
  222. that.setData({
  223. hasmore: true
  224. });
  225. }
  226. that.setData({
  227. pageList: data
  228. });
  229. // console.log(data);
  230. if (data.length <= 0) {
  231. that.setData({
  232. ishow: true
  233. });
  234. } else {
  235. that.setData({
  236. ishow: false
  237. });
  238. }
  239. if (isShowLoading) {
  240. uni.hideLoading();
  241. isShowLoading = false;
  242. }
  243. });
  244. },
  245. // 商品详情
  246. goproDetail(e) {
  247. var id = e.currentTarget.dataset.id;
  248. let merchantId = e.currentTarget.dataset.merchant;
  249. let shopId = e.currentTarget.dataset.shopid;
  250. if (!shopId) {
  251. if (!merchantId) {
  252. uni.navigateTo({
  253. url: '/integralshop/detail/detail?id=' + id
  254. });
  255. } else {
  256. uni.navigateTo({
  257. url: '/integralshop/detail/detail?id=' + id + '&merchantId=' + merchantId
  258. });
  259. }
  260. } else {
  261. uni.navigateTo({
  262. url: '/integralshop/detail/detail?id=' + id + '&merchantId=' + merchantId + '&shopId=' +
  263. shopId
  264. });
  265. } // wx.navigateTo({
  266. // url: '/integralshop/detail/detail?id='+id,
  267. // })
  268. },
  269. // 积分规则
  270. goRule() {
  271. uni.navigateTo({
  272. url: "/integralshop/task/index"// /integralshop/integralRule/index
  273. });
  274. },
  275. // 签到
  276. signFun() {
  277. req.postRequest('/api/integral/sign', {}, data => {
  278. if (data) {
  279. req.msg('连续签到' + data.continuityDay + '天' + ',获得' + data.IntegralChange + '积分');
  280. this.setData({
  281. sign: 1
  282. });
  283. this.getIntegral();
  284. }
  285. });
  286. },
  287. // 积分明细
  288. goDetailed() {
  289. uni.navigateTo({
  290. url: "/integralshop/integralDetailed/index"
  291. });
  292. },
  293. // 分数排序
  294. fraction(e) {
  295. var dt = e.currentTarget.dataset;
  296. this.isLoad = true;
  297. this.setData({
  298. isShow: false
  299. });
  300. this.refresh(dt.v);
  301. },
  302. ss(e) {
  303. var dt = e.currentTarget.dataset;
  304. if (dt.v == 'fraction') {
  305. this.setData({
  306. isShow: true
  307. });
  308. } else {
  309. this.setData({
  310. isShow: false
  311. });
  312. }
  313. if (dt.v == 'default') {
  314. this.isLoad = true;
  315. this.refresh(dt.v);
  316. }
  317. if (dt.v == 'stock') {
  318. this.isLoad = true;
  319. this.refresh(dt.v);
  320. } // this.data.isLoad = true;
  321. // this.refresh(dt.v);
  322. this.setData({
  323. active: dt.v
  324. });
  325. },
  326. refresh(s, t) {
  327. this.setData({
  328. hasemore: true,
  329. sort: s
  330. });
  331. this.page = 1;
  332. this.getProct();
  333. },
  334. eliminate() {
  335. this.setData({
  336. isShow: false
  337. });
  338. }
  339. }
  340. };
  341. </script>
  342. <style>
  343. @import "./index.css";
  344. </style>