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

68
pages/index/checkShop.vue

@ -8,13 +8,13 @@
:options="options1" :options="options1"
index="1" index="1"
v-for="item in shopList" v-for="item in shopList"
:key="item.id" :key="item.shopId"
@click="onActionItemSwipe(item)" @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"> <view class="swipe-action__content">
<text class="swipe-action__content__text">{{ item.shopName }}</text> <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> <u-icon color="#1ba035" name="checkmark-circle-fill"></u-icon>
</view> </view>
</view> </view>
@ -71,38 +71,45 @@ export default {
shopNameOld: '', shopNameOld: '',
shopList: [], shopList: [],
shopId: null, shopId: null,
current: '' current: '',
name:''
} }
}, },
onLoad() { onLoad() {
this.getList() this.getList()
}, },
mounted() {
console.log(this.shopIndex)
this.current = this.shopIndex
},
methods: { methods: {
...mapMutations(['setShopIndex']), ...mapMutations(['setShopIndex']),
submit() { submit() {
const shop = this.shopList.find(v => v.id === this.current) this.tui.request("/auth/chooseShop", "POST", {
if (shop.hasOwnProperty('id')) { shopId: this.current
this.setShopIndex(shop) }, false, true).then((res) => {
this.tui.toast('切换店铺名称成功!', 2000,) if (res.code == 200) {
setTimeout(() => { uni.setStorageSync('shopName',this.name)
uni.reLaunch({ this.tui.toast('切换店铺成功', 2000, true)
url: '/pages/index/index' setTimeout(() => {
// url: '/pages/index/index' uni.reLaunch({
}) url: '/pages/index/index'
}, 200) })
} }, 200)
}, } else {
this.tui.toast(res.message)
return
}
}).catch((res) => {})
},
//初始化店铺列表
getList() { getList() {
this.tui.request("/app/shop/getAll", "get", { this.tui.request("/auth/getShopByUser", "post", {
// shopId: 1, // shopId: 1,
}, false, true).then((res) => { }, false, true).then((res) => {
if(res.code == 200){ if(res.code == 200){
console.log(this.shopIndex) for (let i=0;i<res.result.length;i++) {
this.shopList = res.result if(res.result[i].shopName ==uni.getStorageSync('shopName')){
this.current = res.result[i].shopId
}
}
this.shopList = res.result
}else{ }else{
this.tui.toast(res.message) this.tui.toast(res.message)
} }
@ -114,14 +121,17 @@ export default {
this.shopName = '' this.shopName = ''
this.shopId = '' this.shopId = ''
this.shopNameOld = '' this.shopNameOld = ''
}, },
//编辑
onActionItemSwipe(item) { onActionItemSwipe(item) {
this.popupShow = true this.popupShow = true
this.shopNameOld = item.shopName this.shopNameOld = item.shopName
this.shopId = item.id this.shopId = item.shopId
}, },
onActionItemClick(id) { //切换店铺
this.current = id onActionItemClick(item) {
this.current = item.shopId
this.name = item.shopName
}, },
onEditSave() { onEditSave() {
if (!this.shopName) return this.tui.toast('请输入新店铺名称', 2000,) 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', src: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
inventoryList: [], inventoryList: [],
settingShow: false, settingShow: false,
chartData: {}, chartData: {},
shopName:'',
//您可以通过修改 config-ucharts.js 文件中下标为 ['line'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。 //您可以通过修改 config-ucharts.js 文件中下标为 ['line'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
opts: { opts: {
// color: ["#1890FF", "#73C0DE"], // color: ["#1890FF", "#73C0DE"],
@ -189,8 +190,8 @@
onLoad() { onLoad() {
this.getSaleInfo() this.getSaleInfo()
this.getServerData(); this.getServerData();
this.getOrderInfoList(); this.getOrderInfoList();
console.log(this.shopIndex, 'index', this.shopName); this.shopName = uni.getStorageSync('shopName')
}, },
methods: { methods: {
// changeMall(e) { // changeMall(e) {

24
pages/login/login.vue

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

Loading…
Cancel
Save