积分超市

This commit is contained in:
liuye
2022-02-17 10:31:45 +08:00
parent 0be49b0432
commit 1325b90054
7 changed files with 277 additions and 303 deletions

View File

@@ -192,7 +192,7 @@ export default {
// uni.setNavigationBarTitle({ // uni.setNavigationBarTitle({
// title: options.title, // title: options.title,
// }); // });
// this.getInfo(); this.getInfo();
}, },
methods: { methods: {
tabClick(index) { tabClick(index) {

View File

@@ -1,39 +1,24 @@
<template> <template>
<div class="page"> <div class="AppSupermarket">
<div class="supermarket"> <AiTopFixed>
<div <div class="header-top">
class="fixed-top title" <div>区域选择</div>
@click="$linkTo(`./system?areaName=${areaName}`)" <AiAreaPicker v-model="areaId" :areaId="user.areaId" @select="areaSelect" :name.sync="areaName">
v-if="propAreaId == '341021104000'" <span class="label" v-if="areaName">{{ areaName }}</span>
> <span v-else>请选择</span>
{{ areaName }}信用好超市管理制度点击查看 >> <u-icon name="arrow-right" color="#666" size="24" style="margin-left:4px;" />
</AiAreaPicker>
</div> </div>
<div </AiTopFixed>
class="goods-list" <div class="goods-list" v-if="numList.length">
v-if="numList.length"
:style="
propAreaId == '341021104000'
? 'padding-top: 80rpx;'
: 'padding-top: 0;'
"
>
<div class="left"> <div class="left">
<div <div :class="numIndex == index ? 'item active' : 'item'" v-for="(item, index) in numList" :key="index" @click="numClick(index)">
:class="numIndex == index ? 'item active' : 'item'" <span v-show="item.total > 0">{{ item.total }}</span>
v-for="(item, index) in numList"
:key="index"
@click="numClick(index)"
>
<i v-show="item.total > 0">{{ item.total }}</i>
{{ item.type }}分区 {{ item.type }}分区
</div> </div>
</div> </div>
<div class="right"> <div class="right">
<div <div class="item" v-for="(item, index) in goodsList[numIndex]" :key="index">
class="item"
v-for="(item, index) in goodsList[numIndex]"
:key="index"
>
<img :src="item.photo[0].url" alt="" /> <img :src="item.photo[0].url" alt="" />
<div class="item-info"> <div class="item-info">
<p class="item-name">{{ item.merchandiseName }}</p> <p class="item-name">{{ item.merchandiseName }}</p>
@@ -44,16 +29,9 @@
<div class="item-bottom"> <div class="item-bottom">
<div></div> <div></div>
<div class="item-bottom__right"> <div class="item-bottom__right">
<image <image v-show="item.num > 0" @click="cut(numIndex, index)" src="./components/img/cut.png"/>
v-show="item.num > 0"
@click="cut(numIndex, index)"
src="/static/img/cut.png"
/>
<input v-show="item.num > 0" v-model="item.num" /> <input v-show="item.num > 0" v-model="item.num" />
<image <image src="./components/img/add.png" @click="add(numIndex, index)" />
src="/static/img/add.png"
@click="add(numIndex, index)"
/>
</div> </div>
</div> </div>
</div> </div>
@@ -62,13 +40,6 @@
</div> </div>
<AiEmpty v-else /> <AiEmpty v-else />
<div class="goods-footer" v-if="numList.length"> <div class="goods-footer" v-if="numList.length">
<div class="goods-footer__top">
<h2>
{{ userInfo.familyName || user.nickName
}}{{ userInfo.familyName ? "家" : "" }}
</h2>
<span>剩余积分:{{ userInfo.familyIntegral || 0 }}</span>
</div>
<div class="goods-footer__bottom"> <div class="goods-footer__bottom">
<div class="goods-footer__bottom__left"> <div class="goods-footer__bottom__left">
<h3>{{ total }}件商品</h3> <h3>{{ total }}件商品</h3>
@@ -88,7 +59,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
import { mapState } from "vuex"; import { mapState } from "vuex";
@@ -102,14 +72,14 @@ export default {
numIndex: 0, numIndex: 0,
goodsList: [], goodsList: [],
areaId: "", areaId: "",
userInfo: {},
areaName: "", areaName: "",
userInfo: {},
propAreaId: "", propAreaId: "",
}; };
}, },
computed: { computed: {
...mapState(["global", "user", "token"]), ...mapState(["user"]),
total() { total() {
let total = 0; let total = 0;
@@ -141,65 +111,17 @@ export default {
}, },
onLoad() { onLoad() {
this.propAreaId = this.$areaId; // this.getList()
uni.$on("update", () => { this.areaName = this.user.areaName || ''
this.getInfo();
});
if (uni.getStorageSync("areaId")) {
this.areaId = uni.getStorageSync("areaId");
}
this.getUserInfo();
this.getInfo();
}, },
onShow() { onShow() {
this.getUserInfo(); document.title = '信用好超市'
}, },
methods: { methods: {
getInfo() {
this.$http
.post(`/admin/area/queryAreaByAreaid?id=${this.areaId}`, null, {})
.then((res) => {
if (res.code === 0) {
if (res.data) {
this.areaName = res.data.name;
this.getList();
}
}
});
},
getUserInfo() {
this.$http
.post(
`/app/appresident/queryFamilyById?id=${this.user.residentId}`,
null,
{}
)
.then((res) => {
if (res.code === 0) {
this.userInfo = res.data;
}
});
},
toOrder() { toOrder() {
if (this.user.status == 0) {
if (!this.user.phone) {
return this.$linkTo("/pages/phone/bingPhoneNumber?from=auth");
} else {
return this.$linkTo("/pages/auth/authenticationInfo");
}
}
if (!this.total) { if (!this.total) {
return this.$toast("请选择商品"); return this.$u.toast("请选择商品");
} }
if (this.money > this.userInfo.familyIntegral) {
return this.$toast("积分不足");
}
let goods = []; let goods = [];
this.goodsList.forEach((arr) => { this.goodsList.forEach((arr) => {
@@ -210,25 +132,18 @@ export default {
}); });
}); });
this.$linkTo( uni.navigateTo({ url: `./SubmitOrder?goods=${JSON.stringify(goods)}&total=${this.total}&money=${this.money}&areaId=${this.areaId}` })
`/subPages/creditPoints/submitOrder?familyId=${ },
this.userInfo.familyId areaSelect(e) {
}&userName=${this.userInfo.familyName}&memberId=${ if(/[^0]0{0,2}$/.test(e)) {
this.userInfo.memberId this.areaId = e
}&goods=${JSON.stringify(goods)}&total=${this.total}&money=${ this.getList()
this.money }else {
}&familyIntegral=${this.userInfo.familyIntegral}` this.$u.toast('请选择到村级')
); }
}, },
getList() { getList() {
this.$http this.$http.post(`/app/appvillagerintegralmerchandise/listByIntegral?areaId=${this.areaId}`).then((res) => {
.post(
`/app/appvillagerintegralmerchandise/listByIntegral?areaId=${this.areaId}`,
null,
{}
)
.then((res) => {
if (res.code === 0) { if (res.code === 0) {
if (res.data) { if (res.data) {
this.numList = Object.keys(res.data).map((item) => { this.numList = Object.keys(res.data).map((item) => {
@@ -289,7 +204,18 @@ export default {
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.item-bottom { uni-page-body{
height: 100%;
background-color: #fff;
}
.header-top {
display: flex;
background: #fff;
justify-content: space-between;
align-items: center;
padding-top: 16px;
}
.item-bottom {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@@ -317,13 +243,13 @@ export default {
color: #666; color: #666;
text-align: center; text-align: center;
} }
} }
.goods-footer { .goods-footer {
position: fixed; position: fixed;
left: 0; left: 0;
bottom: 0; bottom: 0;
z-index: 111; z-index: 1;
width: 100%; width: 100%;
background: #fff; background: #fff;
@@ -390,12 +316,9 @@ export default {
justify-content: space-between; justify-content: space-between;
height: 104rpx; height: 104rpx;
} }
} }
.page { .AppSupermarket {
width: 100%;
background-color: #fff;
.supermarket {
height: 100%; height: 100%;
overflow-y: hidden; overflow-y: hidden;
.title { .title {
@@ -434,16 +357,18 @@ export default {
font-size: 28rpx; font-size: 28rpx;
border-left: 6rpx solid #faf9fb; border-left: 6rpx solid #faf9fb;
i { span {
position: absolute; position: absolute;
right: 8rpx; right: 8rpx;
top: 8rpx; top: 8rpx;
height: 28rpx; // width: 28px;;
line-height: 28rpx; height: 28px;
padding: 0 12rpx; line-height: 28px;
padding: 0 8px;
text-align: center;
color: #fff; color: #fff;
font-size: 20rpx; font-size: 10px;
border-radius: 13rpx; border-radius: 14px;
background: #fb4e44; background: #fb4e44;
} }
} }
@@ -505,5 +430,8 @@ export default {
} }
} }
} }
}
i{
font-style: normal;
}
</style> </style>

View File

@@ -1,15 +1,15 @@
<template> <template>
<div class="Search"> <div class="Search">
<AiTopFixed> <AiTopFixed>
<u-search placeholder="请输入标题" :show-action="false" search-icon-color="#ccc" v-model="search.title" @search="search.current = 1, getList()"/> <u-search placeholder="请输入标题" :show-action="false" search-icon-color="#ccc" v-model="phone" @search="getList()"/>
</AiTopFixed> </AiTopFixed>
<p class="text">请通过搜索<span>手机号或身份证号</span>后选择结算对象</p> <div class="family-list" v-if="familyInfo.familyId">
<div class="family-list"> <div class="item" @click="goBack">
<div class="item"> <div class="name">{{familyInfo.familyName}}</div>
<div class="name">卓作旺家</div> <div class="num">剩余积分:{{familyInfo.familyIntegral}}</div>
<div class="num">剩余积分:480</div>
</div> </div>
</div> </div>
<p class="text" v-else>请通过搜索<span>手机号或身份证号</span>后选择结算对象</p>
</div> </div>
</template> </template>
@@ -18,16 +18,30 @@ export default {
name: 'Search', name: 'Search',
data() { data() {
return { return {
search: { phone: '',
title: '', familyInfo: {},
current: 1 areaId: ''
}
}; };
}, },
onLoad(options) {
this.areaId = options.areaId
},
onShow() {
document.title = '搜索'
},
methods: { methods: {
getList() { getList() {
this.$http.post(`/app/appresident/queryFamilyByPhone?phone=${this.phone}&areaId=${this.areaId}`).then(res => {
if (res.code === 0 && res.data) {
this.familyInfo = res.data
}
}).catch((err) => {
this.$confirm(err, '温馨提示').then()
})
},
goBack() {
uni.$emit('selectFamily', this.familyInfo)
uni.navigateBack()
} }
}, },
}; };

View File

@@ -1,10 +1,14 @@
<template> <template>
<div class="order"> <div class="order">
<div class="order-info"> <div class="order-info">
<h2>{{ userName }}</h2> <div><span class="tips">*</span>结算对象</div>
<span>剩余积分:{{ familyIntegral }}</span> <div class="family-name" @click="toSearch">
<span v-if="familyInfo.familyId" class="name">{{familyInfo.familyName}} 剩余积分:{{familyInfo.familyIntegral}}</span>
<span v-else class="name">请选择</span>
<u-icon name="arrow-right" color="#666" size="24" style="margin-left:4px;" />
</div> </div>
<image class="line" src="/static/img/line.png" /> </div>
<image class="line" src="./components/img/line.png" />
<div class="order-list"> <div class="order-list">
<div class="order-item" v-for="(item, index) in goods" :key="index"> <div class="order-item" v-for="(item, index) in goods" :key="index">
<image :src="item.photo[0].url" /> <image :src="item.photo[0].url" />
@@ -33,7 +37,7 @@
<em>积分</em> <em>积分</em>
</div> </div>
</div> </div>
<div class="goods-footer__bottom--btn" @click="submit" hover-class="text-hover">确认提交</div> <div class="goods-footer__bottom--btn" @click="submit" hover-class="text-hover">确认领取</div>
</div> </div>
</div> </div>
</div> </div>
@@ -46,29 +50,36 @@
total: 0, total: 0,
money: 0, money: 0,
goods: [], goods: [],
memberId: '', areaId: '',
userName: '', familyInfo: {}
familyId: '',
familyIntegral: 0
} }
}, },
onLoad (query) { onLoad (options) {
this.userName = query.userName this.total = options.total
this.total = query.total this.money = options.money
this.familyIntegral = query.familyIntegral this.goods = JSON.parse(options.goods)
this.money = query.money this.areaId = options.areaId
this.memberId = query.memberId uni.$on('selectFamily', res => {
this.familyId = query.familyId console.log(res)
this.goods = JSON.parse(query.goods) this.familyInfo = res
})
},
onShow() {
document.title = '结算'
}, },
methods: { methods: {
submit () { toSearch() {
this.$loading() uni.navigateTo({url: `./Search?areaId=${this.areaId}`})
},
submit() {
if(!this.familyInfo.familyId) {
return this.$u.toast('请选择结算对象')
}
this.$http.post(`/app/appvillagerintegralshoporder/createOrderForWx`, { this.$http.post(`/app/appvillagerintegralshoporder/createOrderForWx`, {
memberId: this.memberId, memberId: this.familyInfo.memberId,
familyId: this.familyId, familyId: this.familyInfo.familyId,
orderIntegral: this.money, orderIntegral: this.money,
shopId: this.goods[0].shopId, shopId: this.goods[0].shopId,
merchandiseList: this.goods.map(item => { merchandiseList: this.goods.map(item => {
@@ -79,10 +90,9 @@
}) })
}).then(res => { }).then(res => {
if (res.code === 0) { if (res.code === 0) {
uni.$emit('update')
this.$linkTo('/subPages/creditPoints/result?type=0')
} else { } else {
this.$linkTo('/subPages/creditPoints/result?type=1')
} }
}) })
} }
@@ -142,12 +152,30 @@
.order-info { .order-info {
display: flex; display: flex;
align-items: center;
justify-content: space-between; justify-content: space-between;
height: 128rpx; font-size: 32px;
padding: 0 30rpx; font-family: PingFangSC-Regular, PingFang SC;
color: #333333; color: #333;
font-size: 32rpx; line-height: 44px;
padding: 40px 30px 20px 30px;
.tips{
display: inline-block;
width: 16px;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #FF4466;
margin-right: 4px;
}
.family-name{
color: #666;
width: calc(100% - 170px);
.name{
display: inline-block;
width: calc(100% - 40px);
word-break: break-all;
text-align: right;
}
}
} }
.goods-footer { .goods-footer {
@@ -179,6 +207,7 @@
h3 { h3 {
color: #F94246; color: #F94246;
font-size: 32rpx; font-size: 32rpx;
font-weight: normal;
} }
.goods-footer__bottom--middle { .goods-footer__bottom--middle {
@@ -241,4 +270,7 @@
} }
} }
} }
i{
font-style: normal;
}
</style> </style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B