chenkainan 5 months ago
parent
commit
f8728b52ab
  1. 2
      components/addressAdd.vue
  2. 26
      components/cartData.vue
  3. 8
      pages/login/login.vue
  4. 11
      static/js/request.js
  5. 11
      subPackages/techan/detail.vue
  6. 48
      subPackages/techan/index.vue
  7. 12
      subPackages/techan/order.vue

2
components/addressAdd.vue

@ -113,7 +113,7 @@
let that = this let that = this
that.Post({}, '/api/areas/getAll').then(res => { that.Post({}, '/api/areas/getAll').then(res => {
if (res.code === 1) { if (res.code === 200) {
var data = res.data; var data = res.data;
var result = {}; var result = {};
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {

26
components/cartData.vue

@ -27,7 +27,7 @@
</view> </view>
<view style="padding-left: 26rpx;flex:1"> <view style="padding-left: 26rpx;flex:1">
<view class="commodity box" > <view class="commodity box" >
<image class="img" :src="showImg(item.Specifications_image)" mode="aspectFill"></image> <image class="img" :src="showImg(item.specifications_image)" mode="aspectFill"></image>
<view class="title goods-text-area"> <view class="title goods-text-area">
<view class="commodity-info"> <view class="commodity-info">
<view class="text-overflowRows" style="font-weight: bold;">{{ item.good_name }}</view> <view class="text-overflowRows" style="font-weight: bold;">{{ item.good_name }}</view>
@ -50,6 +50,7 @@
</view> </view>
</view> </view>
<view style="width: 1rpx;height: 50rpx;"></view>
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
@ -138,8 +139,13 @@
this.setAllSelect() this.setAllSelect()
} else { } else {
this.Post({noForceLogin: true},'/api/shopping/getShoppingList').then(res => { this.Post({noForceLogin: true},'/api/shopping/getShoppingList').then(res => {
if (res) { if (res && res.data) {
this.cartData = (res.data || []).map(v=>{return {...v, isSelected:selectedData.includes(v.specifications_id)}}) let tempData = new Array();
(res.data.merchant||[]).forEach(v=>{
tempData = tempData.concat(v.data || [])
})
this.cartData = tempData.map(v=>{return {...v, isSelected:selectedData.includes(v.specifications_id)}})
this.setAllSelect() this.setAllSelect()
} }
}) })
@ -226,11 +232,20 @@
icon:'none', icon:'none',
}) })
return return
} }
let merchant_ids = this.cartData.filter(v=>v.isSelected).map(v=>v.merchant_id)
if (merchant_ids.some(v=>v!=merchant_ids[0])) {
uni.showToast({
title:'购物车只可下单同一供应商的产品',
icon:'none',
})
return
}
let orderData = this.cartData.filter(v=>v.isSelected).map(v=>{ let orderData = this.cartData.filter(v=>v.isSelected).map(v=>{
return { return {
goodsInfo: { goodsInfo: {
image: v.Specifications_image, image: v.specifications_image,
title:v.good_name, title:v.good_name,
merchant_name: v.merchant_name, merchant_name: v.merchant_name,
}, },
@ -275,7 +290,6 @@
flex-direction: column; flex-direction: column;
background-color: white; background-color: white;
height: 933rpx; height: 933rpx;
padding-bottom: 184rpx;
border-radius: 20rpx 20rpx 0rpx 0rpx; border-radius: 20rpx 20rpx 0rpx 0rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;

8
pages/login/login.vue

@ -98,6 +98,14 @@ export default {
uni.getUserInfo({ uni.getUserInfo({
withCredentials: true, withCredentials: true,
success: (res) => { success: (res) => {
this.Post({
mobile: '18639595995',
captcha: '123456'
}, '/api/user/mobilelogin').then(res=>{
this.$store.commit('changeUserInfo', res.data.userinfo);
this.navigateBasedOnPath();
})
return
this.Post({ this.Post({
code: loginRes.code, code: loginRes.code,
userInfo: res.userInfo, userInfo: res.userInfo,

11
static/js/request.js

@ -20,6 +20,13 @@ const getToken = () => {
// 定义错误处理函数 noForceLogin 不强制登录 // 定义错误处理函数 noForceLogin 不强制登录
const handleError = (res, reject, noForceLogin) => { const handleError = (res, reject, noForceLogin) => {
if (res.data?.code === 401) {
if (noForceLogin) {
reject(res)
return
}
store.commit('changeLoginPath');
}
setTimeout(() => { setTimeout(() => {
uni.showToast({ uni.showToast({
title: res.data?.msg || res.msg, title: res.data?.msg || res.msg,
@ -27,10 +34,6 @@ const handleError = (res, reject, noForceLogin) => {
}); });
reject(res); reject(res);
}, 0); }, 0);
if (res.data?.code === 401) {
if (noForceLogin) { return }
store.commit('changeLoginPath');
}
}; };
// 挂载到 Vue 原型上 // 挂载到 Vue 原型上

11
subPackages/techan/detail.vue

@ -48,9 +48,9 @@
</view> </view>
</view> </view>
<view class="notice" > <view class="notice" v-if="info.reserve_content">
<view class="title">购买须知</view> <view class="title">购买须知</view>
<view class="rich-text" v-html="formateRichText(info.special_content)"></view> <view class="rich-text" v-html="formateRichText(info.reserve_content)"></view>
</view> </view>
<view class="notice" > <view class="notice" >
<view class="title">商品须知</view> <view class="title">商品须知</view>
@ -81,8 +81,9 @@
<view class="left-box"> <view class="left-box">
<view class="img-box" slot="content"> <view class="img-box" slot="content">
<uni-badge class="uni-badge-left-margin" :text="paramData.num" absolute="rightTop" :offset="[5, 5]" size="small" <uni-badge class="uni-badge-left-margin" :text="paramData.num" absolute="rightTop" :offset="[5, 5]" size="small"
:custom-style="{background:'#D90F01',color:'#ffffff',border:'1px solid #ffffff'}"29fd015f8c779f08e53d1016d3643c58wCartClick" :src="showImg('/uploads/20250513/cc33cde475ce45c274cb304e20805aa1.png')" mode="aspectFill" :custom-style="{background:'#D90F01',color:'#ffffff',border:'1px solid #ffffff'}">
style="width: 60rpx;height: 50rpx;"></image> <image @click.stop="showCartClick" :src="showImg('/uploads/20250513/29fd015f8c779f08e53d1016d3643c58.png')" mode="aspectFill"
style="width: 60rpx;height: 50rpx;"></image>
</uni-badge> </uni-badge>
<text class="text">购物车</text> <text class="text">购物车</text>
</view> </view>
@ -747,7 +748,7 @@
background: #FFFFFF; background: #FFFFFF;
border-radius: 20rpx; border-radius: 20rpx;
.sku-item{ .sku-item{
border-radius: 20rpx; // border-radius: 20rpx;
width: 100%; width: 100%;
padding: 14rpx; padding: 14rpx;
display: flex; display: flex;

48
subPackages/techan/index.vue

@ -4,7 +4,7 @@
<uni-icons type="left" size="20" @click="goBack" style="flex-shrink: 0;"></uni-icons> <uni-icons type="left" size="20" @click="goBack" style="flex-shrink: 0;"></uni-icons>
<view class="input-model"> <view class="input-model">
<uni-icons style="height: 1.4rem;line-height: 1.4rem;" type="search" size="15" color="#ABAAAD" ></uni-icons> <uni-icons style="height: 1.4rem;line-height: 1.4rem;" type="search" size="15" color="#ABAAAD" ></uni-icons>
<input class="input-text" placeholder="请输入商品名称" v-model="searchText" @confirm="search()" @keyup.enter="search()"></text> <input class="input-text" placeholder="请输入商品名称" v-model="searchText" @confirm="search(false)" @keyup.enter="search(false)"></text>
</view> </view>
</view> </view>
@ -45,17 +45,17 @@
</template> </template>
<!-- 搜索 --> <!-- 搜索 -->
<view v-else> <view v-else style="flex: 1;">
<view v-if="searchList.length<=0" class="flex-center" style="width: 100%;height: 100%;flex-direction: column;"> <view v-if="searchList.length<=0" class="flex-center" style="width: 100%;height: 100%;flex-direction: column;">
<!-- <image style="width: 328rpx;height: 450.67rpx;"></image> --> <image style="width: 328rpx;height: 450.67rpx;" :src="showImg('/uploads/20250514/0e5f4c089ba2f3a86d3c6f9d8d818d5b.png')"></image>
<view style="font-weight: 500;font-size: 28rpx;color: #666666; <view style="font-weight: 500;font-size: 28rpx;color: #666666;
text-align: center;margin-top: 67rpx;">暂无搜索结果</view> text-align: center;margin-top: 67rpx;padding-bottom: 300rpx;">暂无搜索结果</view>
</view> </view>
<view style="padding:0 26rpx;background: #FFFFFF;" v-else> <view style="padding:0 26rpx;background: #FFFFFF;min-height: 100%;" v-else>
<view class="flex" style="justify-content: space-between;"> <view class="flex" style="justify-content: space-between;">
<view class="search-result" > <view class="search-result" >
<view v-for="(item,i) in searchList" > <view v-for="(item,i) in searchList" >
<view v-if="i%2==1" class="search-item" :key="i" @click="viewDetail(item.goods)"> <view v-if="i%2==0" class="search-item" :key="i" @click="viewDetail(item.goods)">
<image :src="showImg(item.goods.image)" mode="widthFix"></image> <image :src="showImg(item.goods.image)" mode="widthFix"></image>
<view class="search-container"> <view class="search-container">
<view class="title text-overflowRows">{{item.goods.title}}</view> <view class="title text-overflowRows">{{item.goods.title}}</view>
@ -72,7 +72,7 @@
</view> </view>
<view class="search-result" > <view class="search-result" >
<view v-for="(item,i) in searchList"> <view v-for="(item,i) in searchList">
<view class="search-item" v-if="i%2==0" :key="i" @click="viewDetail(item.goods)"> <view class="search-item" v-if="i%2==1" :key="i" @click="viewDetail(item.goods)">
<image :src="showImg(item.goods.image)" mode="widthFix"></image> <image :src="showImg(item.goods.image)" mode="widthFix"></image>
<view class="search-container"> <view class="search-container">
<view class="title text-overflowRows">{{item.goods.title}}</view> <view class="title text-overflowRows">{{item.goods.title}}</view>
@ -376,16 +376,38 @@
// //
search () { search (isMore) {
this.searchFinish = false if (this.searchText.trim().length<=0) {
this.searchList = [] uni.showToast({
// todo title:'请输入搜索关键字',
this.searchList = [...this.list,...this.list,...this.list,...this.list] icon:'none'
})
return
}
if (!isMore) {
this.searchList = []
this.searchFinish = false
}
this.Post({
name: this.searchText.trim(),
offset: this.searchList.length,
// type: 'pgoods',
limit: 10,
}, '/api/search/search').then(res => {
let resData = (res.data || []).map(v=> {return {id: v.id, goods: v.search_data}})
console.log(resData)
this.searchList = [...this.searchList, ...resData];
this.searchFinish = false
console.log(resData, this.searchList)
if (res.data.length<10) {
this.searchFinish = true
}
})
}, },
}, },
onReachBottom() { onReachBottom() {
if (!this.searchFinish) { if (!this.searchFinish) {
this.search() this.search(true)
} }
console.log(1) console.log(1)
} }

12
subPackages/techan/order.vue

@ -30,7 +30,7 @@
</view> </view>
<view class="adds text-overflowRows">{{ contacts.province_text + contacts.city_text + contacts.district_text + contacts.detail_addr }}</view> <view class="adds text-overflowRows">{{ contacts.province_text + contacts.city_text + contacts.district_text + contacts.detail_addr }}</view>
</view> </view>
<image @click="changeAddressAddPopup('open', '', contacts)" :src="showImg('/uploads/20240827/337cf610ce5924c2a65b7a28b6a4891e.png')" mode="aspectFill"></image> <image @click="changeAddressAddPopup('open', '', contacts)" :src="showImg('/uploads/20250514/dd77d7706bc9bffd2bb928d1772e8413.png')" mode="aspectFill"></image>
</view> </view>
<view v-else class="a-img flex-center" @click.stop="changeAddressAddPopup('open','',{})"> <view v-else class="a-img flex-center" @click.stop="changeAddressAddPopup('open','',{})">
<uni-icons style="width: 32rpx;" type="plusempty" size="14"></uni-icons> <uni-icons style="width: 32rpx;" type="plusempty" size="14"></uni-icons>
@ -182,7 +182,7 @@
<view class="subtitle text-overflowRows">{{ item.province_text + item.city_text + item.district_text + item.detail_addr }}</view> <view class="subtitle text-overflowRows">{{ item.province_text + item.city_text + item.district_text + item.detail_addr }}</view>
</view> </view>
<view> <view>
<img @click.stop="changeAddressAddPopup('open', '', item)" :src="showImg('/uploads/20240827/337cf610ce5924c2a65b7a28b6a4891e.png')" alt="" /> <img @click.stop="changeAddressAddPopup('open', '', item)" :src="showImg('/uploads/20250514/dd77d7706bc9bffd2bb928d1772e8413.png')" alt="" />
</view> </view>
</view> </view>
</view> </view>
@ -266,7 +266,7 @@ export default {
console.log(this.isPost) console.log(this.isPost)
}, },
onShow() { onShow() {
this.coupon = this.$store.state.user.coupon // this.coupon = this.$store.state.user.coupon
this.getAllAddressList(); this.getAllAddressList();
// //
@ -402,7 +402,7 @@ export default {
this.Post({}, '/api/user/consigneeList').then(res => { this.Post({}, '/api/user/consigneeList').then(res => {
let oldId = (this.contacts || {}).id let oldId = (this.contacts || {}).id
console.log(this.contacts) console.log(this.contacts)
if (res.code === 1) this.addressList = res.data || []; if (res.code == 200) this.addressList = res.data || [];
if (this.addressList.some(v=>v.id==oldId)) { if (this.addressList.some(v=>v.id==oldId)) {
this.contacts = this.addressList.find(v=>v.id==oldId) this.contacts = this.addressList.find(v=>v.id==oldId)
this.getPost(); this.getPost();
@ -446,7 +446,7 @@ export default {
// //
async saveAddress () { async saveAddress () {
let res = await this.$refs.addressAddVueRef.postSave() let res = await this.$refs.addressAddVueRef.postSave()
if (res && res.code == 1) { if (res && (res.code == 1 || res.code==200)) {
this.contacts = res.data this.contacts = res.data
this.getAllAddressList(); this.getAllAddressList();
this.changeAddressAddPopup('close') this.changeAddressAddPopup('close')
@ -560,7 +560,7 @@ export default {
).then(res => { ).then(res => {
uni.removeStorageSync('teChanOrder') uni.removeStorageSync('teChanOrder')
uni.removeStorageSync('teChanInfo') uni.removeStorageSync('teChanInfo')
if (res.code == 1) { if (res.code == 1 || res.code==200) {
this.Post( this.Post(
{ {
order_id: res.data.order_id, order_id: res.data.order_id,

Loading…
Cancel
Save