123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- import {
- get,
- post
- } from "../../utils/http";
- Page({
-
- data: {
- tabIndex: 0,
- activityList: [],
- store_id: '',
- swiperIndex: 0,
- goodsList: [],
- groupList:'',
- },
-
- onLoad(options) {
-
- 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])
- }
-
- 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 = this.data.activityList.card[this.data.swiperIndex].card_id
- if(id==147){
- 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() {
-
-
- wx.reLaunch({
- url: '/pages/shoppingMall/shoppingMall',
-
-
-
-
-
-
- })
- },
-
- 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
- })
- }
- })
- },
-
- giftBagDetail(){
- wx.navigateTo({
- url: '/subPackagesE/pages/giftBag/giftBag',
- })
- }
- })
|