123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- // pages/activePage2/activePage2.js
- import {
- get,
- post
- } from "../../utils/http";
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // 分类按钮图片
- classifyList: [
- ['https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%2010%402x.png', 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%205%402x.png'],
- ['https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%204%402x.png', 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%206%402x.png'],
- ['https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%2013%402x.png', 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%207%402x.png'],
- ['https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%203%402x.png', 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%208%402x.png'],
- ['https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%402x.png', 'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220901/%E5%B0%8F%E5%9B%BE%E6%A0%87/%E6%9C%AA%E9%80%89%E4%B8%AD%E5%A4%87%E4%BB%BD%209%402x.png']
- ],
- tabIndex: 0, //项目类别下标
- activityList: [], //活动界面数据列表
- store_id: '', //店铺id
- couponType: ['抵扣券', '满减券', '全额减免券', '卡券'], //优惠券类型
- swiperIndex: 0, //次卡活动轮播图下标
- goodsList: [], //美妆产品商品列表
- groupList:'',// 拼团列表
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // 获取店铺id
- this.setData({
- store_id: wx.getStorageSync('store_id')
- })
- // 获取活动页面数据
- this.getActivityList()
- // 获取拼团列表
- this.getGroupList()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- // 获取商品活动轮播图下标
- onSlideChangeEnd() {
- },
- // 切换项目类别下标来切换图标
- changeTab(e) {
- this.setData({
- tabIndex: e.currentTarget.dataset.index
- })
- },
- // 获取活动页面数据列表
- getActivityList() {
- get('/v2/api/activity', {
- store_id: this.data.store_id
- }, res => {
- if (res.code == 200) {
- // 将商品列表商品单独加到数组里
- let arr = []
- let goodsList = res.data.goods[0].list
- goodsList.map(item1 => {
- arr.push(item1)
- })
- // 将商品两两分组
- let index = 0;
- const newArray = [];
- while (index < arr.length) {
- newArray.push(arr.slice(index, (index += 2)));
- }
- // 判断最后一个元素是否只有一个元素 是的话就将第一个元素加进去
- if (newArray[newArray.length - 1].length == 1) {
- newArray[newArray.length - 1].push(arr[0])
- }
- // 处理新人领券价格去掉00
- res.data.new_user.map(item => {
- item.price = Number(item.price)
- item.full_price = Number(item.full_price)
- })
- this.setData({
- activityList: res.data,
- goodsList: newArray
- })
- }
- })
- },
- // 商品活动轮播图改变
- changeGoodsList(e) {
- // 获取轮播图下标
- let index1 = e.detail.current
- let arr = []
- let goodsList = this.data.activityList.goods[index1].list
- goodsList.map(item1 => {
- arr.push(item1)
- })
- // 将商品两两分组
- let index = 0;
- const newArray = [];
- while (index < arr.length) {
- newArray.push(arr.slice(index, (index += 2)));
- }
- // 判断最后一个元素是否只有一个元素 是的话就将第一个元素加进去
- if (newArray[newArray.length - 1].length == 1) {
- newArray[newArray.length - 1].push(arr[0])
- }
- this.setData({
- goodsList: newArray
- })
- },
- // 新人活动优惠券立即使用跳转到我的优惠券
- useCoupon(e) {
- // 判断是否是新人优惠券不是的话就跳转到领券中心,是的话跳转到优惠券列表
- let couponName = e.currentTarget.dataset.item.name
- if (couponName.indexOf("新人") != -1) {
- wx.navigateTo({
- url: '/pages/coupon/coupon',
- })
- } else {
- wx.navigateTo({
- url: '/pages/couponCenter/couponCenter',
- })
- }
- },
- // 项目活动跳转到项目详情
- projectDetail(e) {
- let id = e.currentTarget.dataset.id
- wx.navigateTo({
- url: `/pages/projectDetail/projectDetail?source=project&id=${id}&store_id=${this.data.store_id}`,
- })
- },
- // 跳转到商品活动商品详情
- productDetail(e) {
- let id = e.currentTarget.dataset.id
- wx.navigateTo({
- url: `/pages/projectDetail/projectDetail?source=goods&id=${id}&store_id=${this.data.store_id}`,
- })
- },
- // 跳转到此卡活动商品详情
- cardDetail(e) {
- let id = e.currentTarget.dataset.id
- let index = e.currentTarget.dataset.index
- if(index==3){
- wx.navigateTo({
- url: '/subPackagesB/pages/groupDetail/groupDetail?id=36',
- })
- return
- }
- wx.navigateTo({
- url: `/pages/projectDetail/projectDetail?source=secondaryCard&id=${id}&store_id=${this.data.store_id}`,
- })
- },
- // 轮播图改变
- changeSwiper(e) {
- this.setData({
- swiperIndex: e.detail.current
- })
- },
- // 跳转到美妆商品列表
- toGoodsList() {
- // var app = getApp()
- // app.globalData.showGoods = true
- wx.reLaunch({
- url: '/pages/shoppingMall/shoppingMall',
- // success: function (e) {
- // var page = getCurrentPages().pop();
- // console.log("page", page)
- // if (page == undefined || page == null) return;
- // page.onPullDownRefresh();
- // }
- })
- },
- // 跳转到老送新优惠券
- gotoSendCoupon() {
- wx.navigateTo({
- url: '/pages/sendFriend/sendFriend',
- })
- },
- // 跳转到我的储值页面
- toStoreValue() {
- wx.navigateTo({
- url: '/pages/storedValue/index',
- })
- },
- // 跳转到拼团
- goGroup() {
- if(this.data.groupList.card_list.length==0&&this.data.groupList.goods_list.length==0){
- wx.showToast({
- title: '活动已结束',
- icon:"none"
- })
- return
- }else{
- wx.navigateTo({
- url: '/subPackagesB/pages/joinGroup/joinGroup',
- })
- }
- },
- // 超过时间拼团结束
- getGroupList() {
- get('v2/api/grouping/list', {
- store_id: this.data.store_id || wx.getStorageSync('store_id')
- }, (res) => {
- if (res.code == 200) {
- this.setData({
- groupList: res.data
- })
- }
- })
- },
- })
|