diff --git a/addons/unishop/uniapp/uni-shop/main.js b/addons/unishop/uniapp/uni-shop/main.js index abc349e..73a7781 100644 --- a/addons/unishop/uniapp/uni-shop/main.js +++ b/addons/unishop/uniapp/uni-shop/main.js @@ -171,6 +171,7 @@ const request = async (url, method = 'GET', data = {}, showMsg = true) => { // 跳转判断是否登录 const navTo = (url, check = true) => { + console.log(1111111111, url) if (check && !Vue.prototype.$store.state.hasLogin) { url = '/pages/public/login'; } diff --git a/addons/unishop/uniapp/uni-shop/pages/category/category.vue b/addons/unishop/uniapp/uni-shop/pages/category/category.vue index 5d72dec..ca0654a 100644 --- a/addons/unishop/uniapp/uni-shop/pages/category/category.vue +++ b/addons/unishop/uniapp/uni-shop/pages/category/category.vue @@ -35,38 +35,40 @@ }, onShareAppMessage(e){ - + }, onLoad(){ this.loadData(); }, methods: { async loadData(){ - var that = this; - //let list = await this.$api.json('cateList'); - let list = await this.$api.request('/category/all'); - if (list) { - uni.stopPullDownRefresh(); - list.forEach(item=>{ - if(item.pid == 0){ - if (that.currentId == 0) { - that.currentId = item.id; + let login = await this.$api.checkLogin(); + if (login) { + var that = this; + //let list = await this.$api.json('cateList'); + let list = await this.$api.request('/category/all'); + if (list) { + uni.stopPullDownRefresh(); + list.forEach(item=>{ + if(item.pid == 0){ + if (that.currentId == 0) { + that.currentId = item.id; + } + this.flist.push(item); //pid为父级id, 没有pid或者pid=0是一级分类 + }else { + this.slist.push(item); //没有图的是2级分类 } - this.flist.push(item); //pid为父级id, 没有pid或者pid=0是一级分类 - }else { - this.slist.push(item); //没有图的是2级分类 - } - }) - + }) + + } } - }, //一级分类点击 tabtap(item){ if(!this.sizeCalcState){ this.calcSize(); } - + this.currentId = item.id; let index = this.flist.findIndex(fitem=>fitem.id === item.id); this.tabScrollTop = this.flist[index].top; @@ -190,7 +192,7 @@ font-size: 26upx; color: #666; padding-bottom: 20upx; - + image{ width: 140upx; height: 140upx; diff --git a/addons/unishop/uniapp/uni-shop/pages/index/index.vue b/addons/unishop/uniapp/uni-shop/pages/index/index.vue index 812bc57..5ee8a60 100644 --- a/addons/unishop/uniapp/uni-shop/pages/index/index.vue +++ b/addons/unishop/uniapp/uni-shop/pages/index/index.vue @@ -120,7 +120,7 @@ {{ item.title }} ¥{{ item.price }} - + 查看全部 More+ @@ -215,7 +215,7 @@ export default { }; }, computed:{ - + }, onLoad() { this.loadData(); @@ -232,52 +232,58 @@ export default { this.loadData(); }, onShareAppMessage(e) { - + }, methods: { /** * 请求静态数据只是为了代码不那么乱 * 分次请求未作整合 */ - loadData() { + async loadData() { let that = this; - - //获取广告图 - uni.request({ - url: that.$unishow + '/ads/index', - success(res) { - let carouselList = res.data.data; - that.titleNViewBackground = carouselList[0].background; - that.swiperLength = carouselList.length; - that.carouselList = carouselList; - } - }); - - //获取菜单栏 - uni.request({ - url: that.$unishow + '/category/menu', - success(res) { - that.menu = res.data.data; - } - }); - - uni.stopPullDownRefresh(); - - this.getFlash(); - - this.getProduct(); + let login = await this.$api.checkLogin(); + if (login) { +//获取广告图 + uni.request({ + url: that.$unishow + '/ads/index', + success(res) { + let carouselList = res.data.data; + that.titleNViewBackground = carouselList[0].background; + that.swiperLength = carouselList.length; + that.carouselList = carouselList; + } + }); + + //获取菜单栏 + uni.request({ + url: that.$unishow + '/category/menu', + success(res) { + that.menu = res.data.data; + } + }); + + uni.stopPullDownRefresh(); + + this.getFlash(); + + this.getProduct(); + } + }, // 获取产品列表 async getProduct() { - let goodsList = await this.$api.request('/product/lists', 'GET', {page:this.page, pagesize:this.pageSize}); - if (goodsList) { - if (goodsList.length > 0) { - goodsList.forEach(item=>{ - this.goodsList.push(item); - }); - this.page++; - } else { - this.$api.msg('没有更多数据'); + let login = await this.$api.checkLogin(); + if (login) { + let goodsList = await this.$api.request('/product/lists', 'GET', {page:this.page, pagesize:this.pageSize}); + if (goodsList) { + if (goodsList.length > 0) { + goodsList.forEach(item=>{ + this.goodsList.push(item); + }); + this.page++; + } else { + this.$api.msg('没有更多数据'); + } } } }, @@ -315,10 +321,10 @@ export default { }, // 跳转页面 navTo(url){ - uni.navigateTo({ + uni.navigateTo({ url - }) - }, + }) + }, // 跳转到商品列表 navToList(fid) { uni.navigateTo({ diff --git a/addons/unishop/uniapp/uni-shop/pages/order/createOrder.vue b/addons/unishop/uniapp/uni-shop/pages/order/createOrder.vue index 8e6d172..14c3ec8 100644 --- a/addons/unishop/uniapp/uni-shop/pages/order/createOrder.vue +++ b/addons/unishop/uniapp/uni-shop/pages/order/createOrder.vue @@ -17,15 +17,15 @@ --> - + - - @@ -173,7 +173,7 @@ if (options.hasOwnProperty('cart')) { this.cart = options.cart; - // 从购物车进入 + // 从购物车进入 this.getOrderCreate({ cart: options.cart }); @@ -238,7 +238,7 @@ this.couponList = data.coupon; this.deliveryList = data.delivery; this.calcTotal(); - + if (data.flash) { this.progress = data.flash; } @@ -262,7 +262,7 @@ this.payType = type; }, async submit() { - + // // 如果没有地址则提示先加地址 // if (!this.addressData || !this.addressData.hasOwnProperty('city_id')) { // this.$api.msg('请选择收货地址'); @@ -277,7 +277,7 @@ let coupon_id = 0; if (this.couponList && this.couponList[this.useCouponIndex] && this.couponList[this.useCouponIndex].id) { coupon_id = this.couponList[this.useCouponIndex].id; - } + } let data = { // city_id: this.addressData.city_id, // address_id: this.addressData.id, @@ -305,11 +305,11 @@ let result = await this.$api.request(apiUrl, 'POST', data); if (result) { this.submitLock = false; // 解除锁 - this.$api.msg('已提交', 2000); + this.$api.msg('已提交', 2000); uni.redirectTo({ url: `/pages/money/pay?order_id=${result.order_id}&total=${this.total}&out_trade_no=${result.out_trade_no}` }); - } + } this.submitLock = false; // 解除锁 }, stopPrevent() {}, @@ -364,29 +364,29 @@ // first_fee: "0.00" // 首单价钱 // additional: 1 // 续件数量 // additional_fee: "0" // 续件价钱 - let delivery = this.deliveryList[this.deliveryIndex]; - if (delivery) { - let deliveryPrice = 0; - if (delivery.hasOwnProperty('id')) { - if (delivery.min > number) { - this.$api.msg('必须至少购买' + delivery.min + '件商品才能使用此配送方式', 6000) - } - // 如何为0就赋值1,不然下面的循环会死循环 - delivery.first = delivery.first == 0 ? 1 : delivery.first; - delivery.additional = delivery.additional == 0 ? 1 : delivery.additional; - for (let i = 0; i < number;) { - if (i === 0) { - deliveryPrice = deliveryPrice + parseInt(delivery.first_fee); - i = i + parseInt(delivery.first); - } else { - deliveryPrice = deliveryPrice + parseInt(delivery.additional_fee); - i = i + parseInt(delivery.additional); - } - } - } - this.deliveryPrice = deliveryPrice.toFixed(2); - total = total + deliveryPrice; - } + // let delivery = this.deliveryList[this.deliveryIndex]; + // if (delivery) { + // let deliveryPrice = 0; + // if (delivery.hasOwnProperty('id')) { + // if (delivery.min > number) { + // this.$api.msg('必须至少购买' + delivery.min + '件商品才能使用此配送方式', 6000) + // } + // // 如何为0就赋值1,不然下面的循环会死循环 + // delivery.first = delivery.first == 0 ? 1 : delivery.first; + // delivery.additional = delivery.additional == 0 ? 1 : delivery.additional; + // for (let i = 0; i < number;) { + // if (i === 0) { + // deliveryPrice = deliveryPrice + parseInt(delivery.first_fee); + // i = i + parseInt(delivery.first); + // } else { + // deliveryPrice = deliveryPrice + parseInt(delivery.additional_fee); + // i = i + parseInt(delivery.additional); + // } + // } + // } + // this.deliveryPrice = deliveryPrice.toFixed(2); + // total = total + deliveryPrice; + // } this.total = total.toFixed(2); }, diff --git a/addons/unishop/uniapp/uni-shop/pages/user/user.vue b/addons/unishop/uniapp/uni-shop/pages/user/user.vue index 33a490b..a32ad23 100644 --- a/addons/unishop/uniapp/uni-shop/pages/user/user.vue +++ b/addons/unishop/uniapp/uni-shop/pages/user/user.vue @@ -1,6 +1,6 @@ -