初始化产品库

This commit is contained in:
aixianling
2021-11-15 10:29:05 +08:00
parent 8f735a4ffe
commit 5440b43b9c
306 changed files with 54508 additions and 3 deletions

View File

@@ -0,0 +1,286 @@
<template>
<div class="balance">
<div class="operate">
<div class="target">结算对象</div>
<div class="select" @click="handleSelect">
{{
selected
? `${selected.familyName} 剩余积分:${selected.familyIntegral}`
: '请选择'
}}
<u-icon name="arrow-right" color="#E2E2E2" size="28"></u-icon>
</div>
</div>
<div class="line" :style="{ backgroundImage: 'url(' + uri + ')' }"></div>
<scroll-view scroll-y class="category-wrap">
<div
class="category-item"
v-for="(item, index) in categoryList"
:key="index"
>
<img class="category-img" :src="parseObj(item.photo)" alt="" />
<div class="category-info">
<label class="hidden">{{ item.merchandiseName }}</label>
<span class="score"
>{{ item.costIntegral }}
<span>积分</span>
</span>
<div class="wrap">×{{ item.merchandiseNumber }}</div>
</div>
</div>
</scroll-view>
<div class="footer">
<div class="sum">
<span>{{ totalCount }}件商品</span>
<span
>合计{{ totalScore }}
<span>积分</span>
</span>
</div>
<div class="btn" @click="hanldeSubmit">确认领取</div>
</div>
<back />
</div>
</template>
<script>
import Back from '../../components/AiBack'
export default {
name: 'balance',
components: { Back },
data() {
return {
selected: null,
categoryList: [],
totalScore: 0,
totalCount: 0
}
},
onLoad(opt) {
if (opt.category) {
let sum = 0
let count = 0
this.categoryList = JSON.parse(opt.category)
this.categoryList.map(e => {
count += e.merchandiseNumber
if (e.merchandiseNumber != 0) {
sum += e.merchandiseNumber * e.costIntegral
}
})
this.totalScore = sum
this.totalCount = count
}
uni.$on('selected', data => {
if (data) {
this.selected = data
}
})
},
computed: {
uri() {
return this.imgOtherUrl + 'line.png'
}
},
methods: {
parseObj(json) {
return JSON.parse(json || '[]')[0]?.url
},
hanldeSubmit() {
if (!this.selected)
return uni.showToast({
title: '请选择结算对象',
icon: 'none'
})
let { memberId, familyId } = this.selected
this.$http
.post(`/app/appvillagerintegralshoporder/addOrder`, {
shopId: this.categoryList[0].shopId,
memberId,
familyId,
orderIntegral: this.totalScore,
merchandiseList: this.categoryList.map(e => {
return {
...e,
merchandiseId: e.id
}
})
})
.then(res => {
if (res.code == 0) {
uni.navigateTo({
url: '/pages/supermarket/components/resultPage/resultPage'
})
} else {
uni.navigateTo({
url:
'/pages/supermarket/components/resultPage/resultPage?flag=' +
false
})
}
})
.catch(e => {
uni.showToast({
title: e || '网络异常',
icon: 'none'
})
})
},
handleSelect() {
uni.navigateTo({
url: '/pages/supermarket/search'
})
}
}
}
</script>
<style lang="scss" scoped>
.balance {
min-height: 100%;
background-color: #ffffff;
.operate {
height: 120px;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 0 30px;
.target {
font-size: 32px;
color: #333333;
&:before {
content: '*';
font-size: 32px;
color: #ff4466;
}
}
.select {
font-size: 32px;
color: #666666;
& > i {
font-size: 20px;
}
}
}
.line {
// margin: 0 30px;
padding: 0 15px;
height: 8px;
background-repeat: no-repeat;
background-size: cover;
}
.category-wrap {
padding: 16px 0 110px;
.category-item {
box-sizing: border-box;
padding: 28px 32px 44px 30px;
height: 264px;
display: flex;
.category-img {
width: 192px;
height: 192px;
border: 1px solid #f6f6f6;
flex-shrink: 0;
margin-right: 30px;
}
.category-info {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
& > label {
font-size: 30px;
font-weight: 800;
color: #333333;
line-height: 42px;
}
.score {
font-size: 40px;
font-weight: 600;
color: #fa4a51;
& > span {
font-size: 24px;
color: #fa4a51;
margin-left: 8px;
}
}
.wrap {
display: flex;
justify-content: flex-end;
font-weight: 600;
}
}
}
}
.footer {
display: flex;
align-items: center;
width: 100%;
background-color: #ffffff;
z-index: 100;
height: 104px;
box-shadow: 0px -2px 8px 0px rgba(214, 214, 214, 0.5);
position: fixed;
left: 0;
bottom: 0;
.sum {
width: calc(100% - 212px);
box-sizing: border-box;
padding: 30px;
display: flex;
justify-content: space-between;
& > span:nth-child(1),
span:nth-child(2) {
font-size: 32px;
font-weight: 400;
color: #f94246;
& > span {
font-size: 24px;
margin-left: 12px;
}
}
}
.btn {
width: 212px;
height: 100%;
background-color: #1365dd;
font-size: 36px;
font-weight: 500;
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
}
}
.hidden {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
}
</style>

View File

@@ -0,0 +1,69 @@
<template>
<div class="result-page">
<img :src="imgSrc" alt="">
<text>{{text}}</text>
<u-button type="primary" :custom-style="{width:'100%',borderRadius:'4px',marginTop:'48px'}" @click="goBack">{{btnText}}</u-button>
<back></back>
</div>
</template>
<script>
import Back from "../../../../components/AiBack";
export default {
name: "result-page",
components: {Back},
data() {
return {
flag: true
}
},
onLoad(val) {
if (val.flag) {
this.flag = val.flag
}
},
methods: {
goBack() {
uni.navigateBack({
delta:3
})
}
},
computed: {
text(){
return this.flag ? '领取成功!' : '领取失败!请联系管理员处理'
},
btnText(){
return this.flag ? '确定' : '我知道了'
},
imgSrc(){
return this.flag ? (this.imgOtherUrl + 'kztcg.png') : (this.imgOtherUrl + 'kztsb.png')
}
}
}
</script>
<style lang="scss" scoped>
.result-page {
min-height: 100%;
background-color: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
padding: 96px ;
img {
width: 192px;
height: 192px;
}
text{
font-size: 36px;
font-weight: 800;
color: #333333;
line-height: 50px;
display: flex;
justify-content: center;
}
}
</style>

View File

@@ -0,0 +1,120 @@
<template>
<div class="search">
<div class="search-wrap">
<u-search :show-action="false" placeholder="请输入手机号或身份证号搜索" v-model.trim="keyword" @search="search"></u-search>
</div>
<div class="result-body">
<div class="res-item" v-if="result" @click="selected">
<span>{{result.familyName}}</span>
<span>剩余积分:{{result.familyIntegral}}</span>
</div>
<span class="placeholder" v-else>请通过搜索
<strong>手机号或身份证号</strong>
后选择结算对象
</span>
</div>
<u-modal v-model="show" title="温馨提示" @confirm="confirm" content="该手机号绑定了多个居民,请通过身份证号进行查询"
:confirm-style="{fontWeight:800}"></u-modal>
<back/>
</div>
</template>
<script>
import back from "../../components/AiBack";
export default {
name: "search",
components: {back},
data() {
return {
keyword: "",
show: false,
result: null,
}
},
methods: {
selected() {
uni.navigateBack({
delta: 1,
success: () => {
uni.$emit('selected',this.result)
},
fail: (err) => {
console.error(err)
}
})
},
search() {
if (this.keyword == "") {
return uni.showToast({
title: "请输入搜索关键字",
icon: 'none'
})
}
this.$http.post(`/app/appresident/queryFamilyByPhone`, null, {
params: {
phone: this.keyword
}
}).then(res => {
if (res && res.data) {
this.result = res.data
}
}).catch(e => {
this.result = null
uni.showToast({
title: e,
icon: 'none'
})
})
},
confirm() {
this.show = false
}
}
}
</script>
<style lang="scss" scoped>
.search {
min-height: 100%;
background-color: #ffffff;
.search-wrap {
width: 100%;
box-sizing: border-box;
padding: 24px 32px;
}
.result-body {
.res-item {
height: 112px;
border-bottom: 1px solid #F5F5F5;
box-sizing: border-box;
padding: 0 56px;
display: flex;
align-items: center;
justify-content: space-between;
& > span {
font-size: 32px;
color: #333333;
}
}
.placeholder {
display: flex;
justify-content: center;
margin-top: 144px;
font-size: 28px;
color: #999999;
& > strong {
color: #135AB8;
}
}
}
}
</style>

View File

@@ -0,0 +1,337 @@
<template>
<section class="supermarket">
<template v-if="Object.keys(list).length">
<div class="nav-left">
<scroll-view scroll-y style="height: 100%;">
<div class="nav-left-item" v-for="(val, key, index) in list" :style="active(key)" :key="index"
@click="clickSort(key,index)">
{{key}}分区
<u-badge size="mini" :count="sortCountList[index]" absolute :offset="[5,5]"></u-badge>
</div>
</scroll-view>
</div>
<div class="nav-right">
<scroll-view scroll-y style="height: 100%;">
<div class="category-item" v-for="(item,index) in categoryList" :key="index">
<img
:src="parseObj(item.photo)"
class="category-img" alt="">
<div class="category-info">
<label class="hidden">{{item.merchandiseName}}</label>
<span class="score">{{item.costIntegral}}
<span>积分</span>
</span>
<div class="wrap">
<div class="lxc-count">
<div class="less" @click="less(item,index)">-</div>
<div class="num">{{item.merchandiseNumber}}</div>
<div class="less" @click="add(item,index)">+</div>
</div>
</div>
</div>
</div>
</scroll-view>
</div>
<div class="footer">
<div class="sum">
<span>{{totalCount}}件商品</span>
<span>合计{{totalScore}}
<span>积分</span>
</span>
</div>
<div class="btn" @click="handleSubmit">去结算</div>
</div>
</template>
<AiEmpty v-else></AiEmpty>
</section>
</template>
<script>
import AiEmpty from "../../components/AiEmpty/AiEmpty";
import {mapState} from "vuex";
export default {
name: "supermarket",
components: {AiEmpty},
data() {
return {
list: {},
idx: 0,
totalScore: 0,
sortCountList: [],
mark: 0,
}
},
onLoad() {
this.getList()
},
watch: {
list: {
handler(val) {
let sum = 0
Object.keys(val).map(e=>{
val[e].map(p=>{
if (p.merchandiseNumber != 0) {
sum += (p.merchandiseNumber) * (p.costIntegral)
}
})
})
this.totalScore = sum
},
immediate: true,
deep: true
}
},
computed: {
...mapState(['user']),
totalCount() {
return this.sortCountList.reduce((pre, cur) => (pre + cur), 0)
},
categoryList() {
return this.idx == 0 ? this.list[Object.keys(this.list)[0]] : this.list[this.idx]
},
},
methods: {
handleSubmit() {
if (this.totalCount == 0) {
return uni.showToast({
title: "您还没有选择商品",
icon: 'none'
})
}
let filter = []
Object.keys(this.list).map(e => {
this.list[e].map(p => {
if (p.merchandiseNumber > 0) {
filter.push(p)
}
})
})
uni.navigateTo({
url: "/pages/supermarket/balance?category=" + JSON.stringify(filter)
})
},
active(key) {
const flag = key == this.idx
return {
borderLeft: flag ? '3px solid #1D58FE' : '',
background: flag ? 'linear-gradient(270deg, #FFFFFF 0%, #FFFFFF 77%, #E7EAFA 100%)' : ''
}
},
add(item, index) {
this.list[this.idx][index]["merchandiseNumber"] = this.list[this.idx][index]["merchandiseNumber"] + 1
this.$set(this.sortCountList, this.mark, this.list[this.idx]?.reduce((pre,curr)=>{
return (pre + curr.merchandiseNumber)
},0))
},
less(item, index) {
if (item.merchandiseNumber > 0) {
this.list[this.idx][index]["merchandiseNumber"] = this.list[this.idx][index]["merchandiseNumber"] - 1
this.$set(this.sortCountList, this.mark, this.list[this.idx]?.reduce((pre,curr)=>{
return (pre + curr.merchandiseNumber)
},0))
}
},
clickSort(key, index) {
this.mark = index
this.idx = key.toString()
},
parseObj(json) {
return JSON.parse(json || '[]')[0]?.url
},
getList() {
this.$http.post(`/app/appvillagerintegralmerchandise/listByIntegral`, null, {
params: {
areaId: this.user?.areaId
}
}).then(res => {
if (res && res.data) {
Object.keys(res.data).map(e => {
res.data[e].map(p => {
p.merchandiseNumber = 0
})
})
this.list = res.data
this.idx = Object.keys(res.data)[0]
this.sortCountList = Array(Object.keys(res.data).length).fill(0)
}
})
}
},
}
</script>
<style lang="scss" scoped>
uni-page-body{
background-color: #ffffff;
}
.supermarket {
background-color: #ffffff;
display: flex;
justify-content: space-between;
padding-bottom: 104px;
.nav-left {
width: 168px;
height: 100%;
.nav-left-item {
height: 104px;
background: #FAF9FB;
display: flex;
align-items: center;
justify-content: center;
font-size: 28px;
color: #333333;
border-top: 1px solid #D8E5FF;
border-left: 2px solid transparent;
position: relative;
&:nth-last-child {
border-bottom: 1px solid #D8E5FF;
}
}
}
.nav-right {
width: calc(100% - 168px - 24px);
height: 100%;
.category-item {
height: 264px;
box-sizing: border-box;
padding: 28px 32px 44px 30px;
display: flex;
.category-img {
width: 192px;
height: 192px;
border: 1px solid #F6F6F6;
flex-shrink: 0;
margin-right: 30px;
}
.category-info {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
& > label {
font-size: 30px;
font-weight: 800;
color: #333333;
line-height: 42px;
}
.score {
font-size: 40px;
font-weight: 600;
color: #FA4A51;
line-height: 40px;
& > span {
font-size: 24px;
color: #FA4A51;
margin-left: 8px;
}
}
.wrap {
display: flex;
justify-content: flex-end;
.lxc-count{
display: flex;
align-items: center;
justify-content: center;
.less{
width: 40px;
height: 40px;
font-size: 20px;
display: flex;
align-items: center;
justify-content: center;
font-size: 36px;
font-weight: 500;
color: #333333;
}
.num{
width: 89px;
height: 61px;
display: flex;
align-items: center;
justify-content: center;
background: #F6F6F6;
border-radius: 10px;
font-size: 28px;
font-weight: 400;
color: #333333;
margin: 0 16px;
}
}
}
}
}
}
.footer {
display: flex;
align-items: center;
width: 100%;
background-color: #ffffff;
z-index: 100;
height: 104px;
box-shadow: 0px -2px 8px 0px rgba(214, 214, 214, 0.5);
position: fixed;
left: 0;
bottom: 0;
.sum {
width: calc(100% - 212px);
box-sizing: border-box;
padding: 30px;
display: flex;
justify-content: space-between;
& > span:nth-child(1), span:nth-child(2) {
font-size: 32px;
font-weight: 400;
color: #F94246;
& > span {
font-size: 24px;
margin-left: 12px;
}
}
}
.btn {
width: 212px;
height: 100%;
background-color: #1365DD;
font-size: 36px;
font-weight: 500;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
}
}
.hidden {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
}
</style>