Browse Source

登录选择店铺、首页切换店铺逻辑

master
tianyi@bogon 3 years ago
parent
commit
713f595cbc
  1. 50
      pages/index/addHangOrder.vue
  2. 68
      pages/index/checkShop.vue
  3. 7
      pages/index/index.vue
  4. 24
      pages/login/login.vue

50
pages/index/addHangOrder.vue

@ -5,7 +5,7 @@
<button size="default" type="default" :value="value" @tap="inputDialogToggle('add')"
hover-class="is-hover">新增挂单</button>
</view>
<view class="order-list" v-for="(item, index) in regList" :key="index" @tap="clickCollapse">
<view class="order-list" v-for="(item, index) in regList" :key="index" @tap="clickCollapse(item)">
<ul>
<li>
<view class="name">
@ -18,12 +18,12 @@
<view class="btn-list">
<view class="bj-btn" @tap.stop="inputDialogToggle('edit', item)">编辑</view>
<view class="bj-btn" @tap.stop="scanCodeAdd">扫码开单</view>
<view class="bj-btn" @tap="toggle('center',item)">语音备注</view>
<view class="bj-btn" @tap.stop="toggle('center',item)">语音备注</view>
</view>
<uni-icons type="bottom" size="25" style="position: absolute;bottom:0;right:30rpx;"></uni-icons>
</li>
</ul>
<view class="order-collapse-item" v-if="isCollapse">
<view class="order-collapse-item" v-if="item.isCollapse">
<view class="collapse-1">
<view class="order-notes">
<text style="color: red;">备注:</text>
@ -32,11 +32,11 @@
<view class="shop-list">
<view class="order-name">
女士连衣裙(HD738206579)
<img src="/static/images/datu.png" @tap="largeImg" alt="">
<img src="/static/images/datu.png" @tap.stop="largeImg" alt="">
</view>
<view class="specs-name">颜色:黑色,尺码:s码 * 2</view>
<view class="specs-name">颜色:黑色,尺码:s码 * 2</view>
<view class="del-icon" @tap="delGoodsPrecs"><uni-icons color="red" type="trash"
<view class="del-icon" @tap.stop="delGoodsPrecs"><uni-icons color="red" type="trash"
size="26"></uni-icons></view>
</view>
</view>
@ -115,7 +115,7 @@
<text>¥2952.00</text>
</view>
<view class="shop-popup-bottom-right">
<view class="bottom-btn" @tap="">选好了</view>
<view class="bottom-btn" @tap="saveGoods">选好了</view>
</view>
</view>
</view>
@ -146,7 +146,6 @@
export default {
data() {
return {
isCollapse: false,
voiceText: '',
recordState: false,
pageNumber: 1,
@ -170,8 +169,12 @@
}
}
this.tui.request("/app/sale/listPages", "POST", obj, false, false).then((res) => {
if (res.code == 200) {
this.regList = res.result.records;
if (res.code == 200) {
for (let i=0;i<res.result.records.length;i++) {
res.result.records[i].isCollapse = false
}
this.regList = res.result.records;
console.log(this.regList)
} else {
this.tui.toast(res.message)
}
@ -180,8 +183,9 @@
})
},
//点击切换折叠状态
clickCollapse() {
this.isCollapse = !this.isCollapse
clickCollapse(item) {
console.log(item)
item.isCollapse = !item.isCollapse
},
change(e) {
console.log('当前模式:' + e.type + ',状态:' + e.show);
@ -253,6 +257,26 @@
})
}
})
},
//选择商品点击选好了
saveGoods(){
let obj = {
saleDetailList: [{
productId: "1695314088038633472",
saleDetailQueryDTO: [{
attributeList: '{"颜色":"s","尺码":"m"}',
productCount: 2
}]
}],
saleId:'XD1718301576285786112'
}
this.tui.request("/app/sale/setSaleDetail", "post", obj, false, false).then((res) => {
if (res.code == 200) {
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
//弹出商品规格选择
toggle(type, id) {
@ -281,10 +305,10 @@
//通过商品id查询商品详细信息
getById(id) {
this.tui.request("/app/product/getById", "POST", {
id: id
id: "XD1718301576285786112"
}, false, true).then((res) => {
if (res.code == 200) {
} else {
this.tui.toast(res.message)
}

68
pages/index/checkShop.vue

@ -8,13 +8,13 @@
:options="options1"
index="1"
v-for="item in shopList"
:key="item.id"
:key="item.shopId"
@click="onActionItemSwipe(item)"
>
<view class="swipe-action u-border-top u-border-bottom" @click="onActionItemClick(item.id)">
<view class="swipe-action u-border-top u-border-bottom" @click="onActionItemClick(item)">
<view class="swipe-action__content">
<text class="swipe-action__content__text">{{ item.shopName }}</text>
<view class="swipe-action__content__icon" v-if="item.id == current">
<view class="swipe-action__content__icon" v-if="item.shopId == current">
<u-icon color="#1ba035" name="checkmark-circle-fill"></u-icon>
</view>
</view>
@ -71,38 +71,45 @@ export default {
shopNameOld: '',
shopList: [],
shopId: null,
current: ''
current: '',
name:''
}
},
onLoad() {
this.getList()
},
mounted() {
console.log(this.shopIndex)
this.current = this.shopIndex
},
methods: {
...mapMutations(['setShopIndex']),
submit() {
const shop = this.shopList.find(v => v.id === this.current)
if (shop.hasOwnProperty('id')) {
this.setShopIndex(shop)
this.tui.toast('切换店铺名称成功!', 2000,)
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
// url: '/pages/index/index'
})
}, 200)
}
},
submit() {
this.tui.request("/auth/chooseShop", "POST", {
shopId: this.current
}, false, true).then((res) => {
if (res.code == 200) {
uni.setStorageSync('shopName',this.name)
this.tui.toast('切换店铺成功', 2000, true)
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
})
}, 200)
} else {
this.tui.toast(res.message)
return
}
}).catch((res) => {})
},
//初始化店铺列表
getList() {
this.tui.request("/app/shop/getAll", "get", {
this.tui.request("/auth/getShopByUser", "post", {
// shopId: 1,
}, false, true).then((res) => {
if(res.code == 200){
console.log(this.shopIndex)
this.shopList = res.result
for (let i=0;i<res.result.length;i++) {
if(res.result[i].shopName ==uni.getStorageSync('shopName')){
this.current = res.result[i].shopId
}
}
this.shopList = res.result
}else{
this.tui.toast(res.message)
}
@ -114,14 +121,17 @@ export default {
this.shopName = ''
this.shopId = ''
this.shopNameOld = ''
},
},
//编辑
onActionItemSwipe(item) {
this.popupShow = true
this.shopNameOld = item.shopName
this.shopId = item.id
},
onActionItemClick(id) {
this.current = id
this.shopId = item.shopId
},
//切换店铺
onActionItemClick(item) {
this.current = item.shopId
this.name = item.shopName
},
onEditSave() {
if (!this.shopName) return this.tui.toast('请输入新店铺名称', 2000,)

7
pages/index/index.vue

@ -140,7 +140,8 @@
src: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
inventoryList: [],
settingShow: false,
chartData: {},
chartData: {},
shopName:'',
//您可以通过修改 config-ucharts.js 文件中下标为 ['line'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
opts: {
// color: ["#1890FF", "#73C0DE"],
@ -189,8 +190,8 @@
onLoad() {
this.getSaleInfo()
this.getServerData();
this.getOrderInfoList();
console.log(this.shopIndex, 'index', this.shopName);
this.getOrderInfoList();
this.shopName = uni.getStorageSync('shopName')
},
methods: {
// changeMall(e) {

24
pages/login/login.vue

@ -30,7 +30,7 @@
</view>
</view>
<view class="login-content" v-else>
<uni-easyinput v-model="phone" :maxlength="11" placeholder="请输入手机号" />
<uni-easyinput v-model="mobile" :maxlength="11" placeholder="请输入手机号" />
<com-zw />
<view class="code-box">
<uni-easyinput type="digit" v-model="code" placeholder="请输入验证码" trim="all" />
@ -57,7 +57,7 @@
<view class="popup-title">
<text>选择登录店铺</text>
</view>
<view class="popup-container" v-for="item in shopList" :key="item" @tap="checkShop(item.id)">
<view class="popup-container" v-for="item in shopList" :key="item" @tap="checkShop(item)">
<text style="display: inline-block">{{item.shopName}}</text>
</view>
</view>
@ -78,7 +78,7 @@
export default {
data() {
return {
phone: '13521030702',
mobile: '13521030702',
username: 'delicacylee',
code: '',
password: '1qazxsw2#',
@ -149,7 +149,7 @@
loginUrl='/auth/login'
} else {
data = {
phone: this.phone,
mobile: this.mobile,
code: this.code,
saveLogin: true,
type: this.wayValue
@ -197,12 +197,12 @@
}).catch((res) => {})
},
//多店铺的时候点击选择需要登录的店铺
checkShop(id) {
this.tui.request("/app/sale/delById", "POST", {
id: id
}, false, false).then((res) => {
checkShop(item) {
this.tui.request("/auth/chooseShop", "POST", {
shopId: item.shopId
}, false, true).then((res) => {
if (res.code == 200) {
uni.setStorageSync('shopName',res.result.shopName)
uni.setStorageSync('shopName',item.shopName)
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
@ -218,10 +218,10 @@
},
sendLoginSms() { // 获取验证码
this.isChoose = false
if (reg(this.phone, this.clock) && this.isChoose == false) {
if (reg(this.mobile, this.clock) && this.isChoose == false) {
this.choose = true
this.setTime()
this.tui.request("/common/captcha/sendLoginSms/" + this.phone, "GET", {
this.tui.request("/common/captcha/sendLoginSms/" + this.mobile, "GET", {
type: this.wayValue
}).then((res) => {
if (res.code == 200) {
@ -233,7 +233,7 @@
this.tui.toast(res.message)
}
}).catch((res) => {})
} else if (reg(this.phone, this.clock) && this.isChoose == true) {
} else if (reg(this.mobile, this.clock) && this.isChoose == true) {
console.log('通过了')
}
},

Loading…
Cancel
Save