zpj 2 年 前
親
コミット
e0c51b3bff

+ 4 - 1
api/express.js

@@ -8,4 +8,7 @@ export const getExpressServe = (data) => request(newsUrl + 'serve', 'post', { ..
 // 代取优惠卷
 export const getExpressCoupon = (data) => request(newsUrl + 'coupon', 'post', { ...data },false)
 // 创建订单
-export const getExpressCreate = (data) => request(newsUrl + 'create', 'post', { ...data },false)
+export const getExpressCreate = (data) => request(newsUrl + 'create', 'post', { ...data },false)
+
+// 创建支付
+export const getExpressPay = (data) => request('/api/expressOrder/' + 'pay', 'post', { ...data },false)

+ 15 - 0
api/member.js

@@ -4,3 +4,18 @@ const newsUrl = '/api/member/'
 // 用户注册登陆
 export const appletLogin = (data) => request(newsUrl + 'appletLogin', 'post', { ...data },false)
 
+// 获取用户地址列表
+export const getAddressList = (data) => request(newsUrl + 'address', 'post', { ...data },false)
+// 获取默认地址
+export const getAddressDefault = (data) => request(newsUrl + 'default', 'post', { ...data },false)
+
+// 新增&编辑地址
+export const saveAddress = (data) => request(newsUrl + 'save_address', 'post', { ...data },false)
+// 获取地址详情
+export const getAddressInfo = (data) => request(newsUrl + 'address_info', 'post', { ...data },false)
+// 删除地址
+export const delAddress = (data) => request(newsUrl + 'del_address', 'post', { ...data },false)
+// 新增&编辑地址时获取学校
+export const getAddressSchool = (data) => request(newsUrl + 'school', 'post', { ...data },false)
+// 新增&编辑地址时获取学校宿舍楼
+export const getAddressDorm = (data) => request(newsUrl + 'dorm', 'post', { ...data },false)

+ 3 - 3
components/en-from/en-select/en-select.vue

@@ -10,12 +10,12 @@
       </view>
     </view>
     <uni-data-picker :popup-title="'选择'+label" :localdata="localData" ref="pickerObj" v-show="showPicker"
-                     @change="pickerChange" :border="false" :clear-icon="false" @popupclosed="setPopupClosed">
+                     @change="pickerChange"  :border="false" :clear-icon="false" @popupclosed="setPopupClosed">
     </uni-data-picker>
   </view>
 </template>
 
-<script>
+<script>	
 export default {
   name: 'en-select',
   props: {
@@ -65,7 +65,6 @@ export default {
       this.setValue()
     },
     'inputValue': function () {
-      console.log(this.inputValue)
       if(this.valueType==='1'){
         this.$emit('input', this.inputValue.join(','))
       }else {
@@ -81,6 +80,7 @@ export default {
       }else if(typeof value==='string'){
         value=value.split(',')
       }
+	  
       if(this.inputValue!==value){
         this.inputValue=value
         this.optionName = "";

+ 13 - 7
pages-address/address.vue

@@ -11,16 +11,16 @@
 			</EnBlank>
 		</view>
 		<view v-else class="scroll-view-css box-border-box p-24">
-			<view class="list-box box-border-box p-24" v-for="(item,i) in 10" :key="i" @click.stop="to(1,item)">
+			<view class="list-box box-border-box p-24" v-for="(item,i) in list" :key="i" @click.stop="to(1,item)">
 				<view class=" mb-8 display-flex">
 					<view class="fs-34 fw-500 mr-10 w-556">
-						<span v-if="true" class="list-box-only fs-24 fc-FF7F00 text-align-center">默认</span>
-						重庆工商职业学校3栋1楼503重1重庆工商职业学校3栋1楼503重1
+						<span v-if="item.is_default == 1" class="list-box-only fs-24 fc-FF7F00 text-align-center">默认</span>
+						{{item.address}}{{item.school_name}}{{item.dorm_name}}
 					</view>
 				</view>
 				<view class="w-520 fs-26 fc-9 align-items-center">
-					<view class="fs-24 fc-9 mr-24">张晓鹏</view>
-					<view class="fs-24 fc-9">18883660721</view>
+					<view class="fs-24 fc-9 mr-24">{{item.consignee}}</view>
+					<view class="fs-24 fc-9">{{item.phone}}</view>
 				</view>
 				
 				<image src="@/static/img/common/edit.png" mode=""></image>
@@ -35,6 +35,7 @@
 </template>
 
 <script>
+	import {getAddressList} from '@/api/member.js'
 	import EnBlank from "@/components/en-utils/en-blank/en-blank";
 	import tools from "@/service/tools.js";
 	export default {
@@ -45,11 +46,16 @@
 			}
 		},
 		onShow() {
-			
+			this.list = [];
+			this.getList();
 		},
 		methods:{
 			getList(){
-				
+				getAddressList().then((res)=>{
+					if(res.code === 1){
+						this.list = res.data;
+					}
+				})
 			},
 			
 			to(type,item){

+ 88 - 35
pages-address/edit-add.vue

@@ -8,8 +8,11 @@
 				<EnInput label="收货人" placeholder="请输入收货人姓名" v-model="fromData.consignee"></EnInput>
 				<EnInput label="电话号码" type="number" placeholder="请输入电话号码" v-model="fromData.phone"></EnInput>
 
-				<EnSelect label="收货学校" placeholder="请选择收货学校" v-model="fromData.id" :localData="schoolList" :valueType="'1'"></EnSelect>
-				<EnSelect label="楼栋" placeholder="请选择楼栋" v-model="fromData.id" :localData="builList" :valueType="'1'"></EnSelect>
+				<EnSelect label="收货学校" placeholder="请选择收货学校" v-model="fromData.school_id" 
+				:localData="schoolList" :valueType="'1'" ></EnSelect>
+				
+				<EnSelect label="楼栋" placeholder="请选择楼栋" v-if="fromData.school_id" v-model="fromData.dorm_id" 
+				:localData="builList" :valueType="'1'" ></EnSelect>
 				
 				<EnInput label="详细地址" placeholder="请输入详细地址" v-model="fromData.address"></EnInput>
 			</view>
@@ -26,14 +29,15 @@
 			</view>
 		</view>
 
-		<view class="box-border-box p-24 bgc-f " @click="save()">
-			<view class="add-box text-align-center fs-34 fc-f mb-20">确定</view>
-			<view class="add-box-1 text-align-center fs-34 fc-41ABF5">删除</view>
+		<view class="box-border-box p-24 bgc-f " >
+			<view class="add-box text-align-center fs-34 fc-f mb-20" @click="save()">确定</view>
+			<view v-if="fromData.id" class="add-box-1 text-align-center fs-34 fc-41ABF5" @click="del()">删除</view>
 		</view>
 	</view>
 </template>
 
 <script>
+	import {getAddressInfo,saveAddress,delAddress,getAddressSchool,getAddressDorm} from '@/api/member.js'
 	import tools from "@/service/tools.js";
 	import EnSelect from "@/components/en-from/en-select/en-select";
 	import EnInput from "@/components/en-from/en-input/en-input";
@@ -59,35 +63,16 @@
 					address: '',
 					is_default: 0,
 					consignee: '',
-					city_names: '',
 					phone: '',
-					province: '',
-					city: '',
-					area: '',
-					lon: '',
-					lat: '',
+					dorm_id:'',
+					school_id:'',
+					
+					dorm_name:'',
+					school_name:'',
 				},
 
-				schoolList: [
-					{
-						value:1,
-						text:'学校1',
-					},
-					{
-						value:2,
-						text:'学校2',
-					}
-				],
-				builList:[
-					{
-						value:1,
-						text:'楼栋1',
-					},
-					{
-						value:2,
-						text:'楼栋2',
-					}
-				],
+				schoolList: [],
+				builList:[],
 				isAJAX: false,
 			}
 		},
@@ -97,16 +82,84 @@
 			} else {
 				this.fromData.id = '';
 			}
+			this.getAddressSchool();
 		},
-		mounted() {
-			
+		watch:{
+			'fromData.school_id'(val){
+				this.getAddressDorm()
+			},
 		},
 		methods: {
 			getInfo(id) {
-				
+				getAddressInfo({id:id}).then((res)=>{
+					if(res.code === 1){
+						this.fromData = res.data;
+						this.fromData.school_id = res.data.school_id + ''
+						this.fromData.dorm_id = res.data.dorm_id + ''
+					}
+				})
+			},
+			getAddressSchool(){
+				let operate_id = uni.getStorageSync('operate_id');
+				getAddressSchool({operate_id:operate_id}).then((res)=>{
+					if(res.code === 1){
+						this.schoolList = res.data.map(obj =>{
+							const {school_id,school_name} = obj;
+							return {value:school_id,text:school_name};
+						});
+						
+					}
+				})
+			},
+			getAddressDorm(){
+				getAddressDorm({school_id:this.fromData.school_id}).then((res)=>{
+					if(res.code === 1){
+						this.builList = res.data.map(obj =>{
+							const {dorm_id,name} = obj;
+							return {value:dorm_id,text:name};
+						});
+					}
+				})
 			},
 			save() {
-				
+				if(this.isAJAX){
+					return
+				}
+				this.isAJAX = true;
+				saveAddress(this.fromData).then((res)=>{
+					if(res.code === 1){
+						tools.success('操作成功');
+						this.isAJAX = false;
+						setTimeout(()=>{
+							uni.reLaunch({
+								url: '/pages-address/address'
+							})
+						},1500)
+					}else{
+						tools.success('操作失败');
+						this.isAJAX = false;
+					}
+				})
+			},
+			del(){
+				if(this.isAJAX){
+					return
+				}
+				this.isAJAX = true;
+				delAddress({id:this.fromData.id}).then((res)=>{
+					if(res.code === 1){
+						tools.success('操作成功');
+						this.isAJAX = false;
+						setTimeout(()=>{
+							uni.reLaunch({
+								url: '/pages-address/address'
+							})
+						},1500)
+					}else{
+						tools.success('操作失败');
+						this.isAJAX = false;
+					}
+				})
 			},
 		},
 	}

+ 36 - 9
pages-takeout/confirm-mod/select-address.vue

@@ -7,23 +7,32 @@
 					<uni-icons @click="closeCoupon" class="box-close" type="closeempty" size="20"></uni-icons>
 				</view>
 				
-				<view class="scroll-view-css">
-					<view class="item-box flex-justify-space align-items-center mb-20" v-for="(item,index) in 10" :key="index">
-						<image v-if="id==i" class="s-icon" src="@/static/img/common/y-select.png" mode=""></image>
+				
+				<view v-if="list.length === 0" class="scroll-view-css">
+					<EnBlank :customSrc='true'>
+						<template v-slot:blankImg>
+							<image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
+						</template>
+					</EnBlank>
+				</view>
+				
+				<view v-else class="scroll-view-css">
+					<view class="item-box flex-justify-space align-items-center mb-20" v-for="(item,index) in list" :key="index" @click.stop="select(item)">
+						<image v-if="id==item.id" class="s-icon" src="@/static/img/common/y-select.png" mode=""></image>
 						<image v-else class="s-icon"src="@/static/img/common/n-select.png" mode=""></image>
 						
 						
 						<view class="">
 							<view class="fs-34 fw-600 w556 mb-12">
-								<span class="list-box-only fs-24 fc-FE9E11 text-align-center mr-8">默认</span>
-								重庆工商职业学校3栋1楼503重1重庆工商职业学校3栋1楼503重1重庆工商职业学校3栋1楼503重1
+								<span v-if="item.is_default == 1" class="list-box-only fs-24 fc-FE9E11 text-align-center mr-8">默认</span>
+								{{item.address}}{{item.school_name}}{{item.dorm_name}}
 							</view>
 							<view class="p-b-20">
-								<span class="mr-24 fs-28 fc-9">张晓鹏</span><span class="fs-28 fc-9">18883660721</span>
+								<span class="mr-24 fs-28 fc-9">{{item.consignee}}</span><span class="fs-28 fc-9">{{item.phone}}</span>
 							</view>
 						</view>
 						
-						<image class="edit-img" src="@/static/img/common/edit.png" mode="" @click="toEdit(1)"></image>
+						<image class="edit-img" src="@/static/img/common/edit.png" mode="" @click.stop="toEdit(1,item)"></image>
 					</view>
 				</view>
 				
@@ -38,20 +47,38 @@
 </template>
 
 <script>
+	import {getAddressList} from '@/api/member.js'
+	import EnBlank from "@/components/en-utils/en-blank/en-blank";
+	import tools from "@/service/tools.js";
+	
 	export default {
+		components:{EnBlank,},
 		data(){
 			return{
-				
+				id:'',
+				list:[],
 			}
 		},
 		methods:{
 			getList(){
-				this.openPop();
+				getAddressList().then((res)=>{
+					if(res.code === 1){
+						this.list = res.data;
+						this.openPop();
+					}
+				})
+			},
+			select(item){
+				if(item.id != this.id){
+					this.$emit('giveAddress',item);
+					this.closeCoupon();
+				}
 			},
 			openPop(){
 				this.$refs.popupAddress.open();
 			},
 			closeCoupon(){
+				this.list = [];
 				this.$refs.popupAddress.close();
 			},
 			toEdit(type,item){

+ 145 - 34
pages-takeout/confirm-order.vue

@@ -7,27 +7,27 @@
 			<view class="box-card box-border-box mb-20 bgc-f">
 				<view class="box-input box-border-box p-b-20 mb-20" @click="selectFun(2)">
 					<view class="flex-justify-space mb-12">
-						<view class="fs-36 fw-600 text-overflow-ellipsis w570">
-							重庆工商职业学校3栋1楼503重庆工 商职业学校3栋1楼503重庆工商职业学校3栋1楼503重庆工 商职业学校3栋1楼503
-						</view>
+						<view v-if="addressData.id" class="fs-36 fw-600 text-overflow-ellipsis w570">{{addressData.address||''}}{{addressData.school_name||''}}{{addressData.dorm_name||''}}</view>
+						<view v-else class="fs-36 fw-600 text-overflow-ellipsis w570">请选择地址</view>
 						<image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
 					</view>
-					<view class="">
-						<span class="mr-24 fs-28 fc-9">张晓鹏</span><span class="fs-28 fc-9">18883660721</span>
+					<view class="" v-if="addressData.id">
+						<span class="mr-24 fs-28 fc-9">{{addressData.consignee||''}}</span><span class="fs-28 fc-9">{{addressData.phone||''}}</span>
 					</view>
 				</view>
-				<view class="box-input flex-justify-space align-items-center box-border-box p-b-20 mb-20" @click="selectFun(3)">
+				
+				<!-- <view class="box-input flex-justify-space align-items-center box-border-box p-b-20 mb-20" @click="selectFun(3)">
 					<view class="fs-28 fw-600">预计送达</view>
 					<view class="align-items-center">
 						<view class="fs-28 fw-400 fc-41ABF5">预计 12:30 送达</view>
 						<image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
 					</view>
-				</view>
+				</view> -->
 				
-				<view v-if="false" class="box-input flex-justify-space box-border-box p-b-20 mb-20">
+				<!-- <view  class="box-input flex-justify-space box-border-box p-b-20 mb-20">
 					<view class="fs-28 fw-600">配送方式</view>
 					<view class="fs-24 fw-400 sd-box fc-FB3D03">送达宿舍</view>
-				</view>
+				</view> -->
 				
 				<view class="p-b-20">
 					<view class=" flex-justify-space box-border-box p-b-20">
@@ -38,7 +38,7 @@
 						</view>
 					</view>
 					<view class="code-box box-border-box flex-wrap-wrap">
-						<view class="code-item fs-28" v-for="(item,i) in codeList" :key="i">{{item}}</view>
+						<view class="code-item fs-28 text-overflow-ellipsis-one" v-for="(item,i) in fromData.pickup_code" :key="i">{{item}}</view>
 					</view>
 				</view>
 				
@@ -47,38 +47,38 @@
 			
 			<view class="box-card box-border-box bgc-f mb-20">
 				<view class="mb-32 b-b-F9F9F9">
-					<view class="fs-28 fw-600 mb-24">宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)</view>
-					<view class="flex-justify-space mb-28" v-for="(item,i) in 3" :key="i">
-						<image class="goods-img" src="@/static/img/my/lqzx-bg.png" mode="scaleToFill"></image>
+					<!-- <view class="fs-28 fw-600 mb-24">宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)</view> -->
+					<view class="flex-justify-space mb-28" v-for="(item,i) in cardData.goods_list" :key="i">
+						<image class="goods-img" :src="item.serve_image" mode="aspectFill"></image>
 						<view class="w376">
 							<view class="fs-28 fw-400 mb-4">
-								鸡公煲单人豪华D套餐(含米饭)鸡公煲单人豪华D套
+								{{item.serve_name}}
 							</view>
-							<view class="fs-24 fc-9 mb-4">微辣</view>
-							<view class="fs-24 fc-9">x1</view>
+							<view class="fs-24 fc-9 mb-4">{{item.serve_desc}}</view>
+							<view class="fs-24 fc-9">x{{item.number}}</view>
 						</view>
-						<view class="fs-32 fw-600">¥59.97</view>
+						<view class="fs-32 fw-600">¥{{Number(item.number * Number(item.price)).toFixed(2)}}</view>
 					</view>
 				</view>
-				<view class="flex-justify-space mb-24">
+				<!-- <view class="flex-justify-space mb-24">
 					<view class="fs-28 fw-400">打包费</view>
 					<view class="fs-32 fw-600">¥3</view>
-				</view>
-				<view class="flex-justify-space mb-24">
+				</view> -->
+				<!-- <view class="flex-justify-space mb-24">
 					<view class="fs-28 fw-400">配送费</view>
 					<view class="fs-32 fw-600">¥3</view>
-				</view>
-				<view class="flex-justify-space mb-24 p-b-20 b-b-F9F9F9" @click="selectFun(1)">
+				</view> -->
+				<!-- <view class="flex-justify-space mb-24 p-b-20 b-b-F9F9F9" @click="selectFun(1)">
 					<view class="fs-28 fw-400">优惠券</view>
 					<view class="align-items-center">
 						<view class="fs-32 fc-FB3D03 fw-600">-¥3</view>
 						<image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
 					</view>
-				</view>
+				</view> -->
 				<view class="text-align-right p-b-20">
-					<span class="fc-9 fs-28">共3件,</span>
+					<span class="fc-9 fs-28">共{{cardData.total_num||0}}件,</span>
 					<span class="fw-400 fc-0 fs-28">合计¥</span>
-					<span class="fw-600 fc-0 fs-44">179.1</span>
+					<span class="fw-600 fc-0 fs-44">{{cardData.total_price||0}}</span>
 				</view>
 			</view>
 			
@@ -88,7 +88,7 @@
 					<view class="fs-28 fw-600 w158">备注</view>
 					<input class="text-align-right fs-28" type="text" placeholder="请填写你的需求">
 				</view>
-				<view class="fs-28 fw-600 mb-16">平台将通过服务通知向你推送最新动态</view>
+				<!-- <view class="fs-28 fw-600 mb-16">平台将通过服务通知向你推送最新动态</view>
 				<view class="p-16 bgc-F3F4F6 b-rad-12 tz-an-f">
 					<view class="fc-0 fw-400 fs-24 mb-4">是否电话通知</view>
 					<view class="fc-9 fw-400 fs-24">若开启,则订单送达系统自动曝光(电话)通知</view>
@@ -98,7 +98,7 @@
 							<view class="r-y"></view>
 						</view>
 					</view>
-				</view>
+				</view> -->
 				<view class="p-b-20"></view>
 			</view>
 			
@@ -117,7 +117,7 @@
 			<view class="flex-justify-space">
 				<view class="align-items-flex-end box-1">
 					<span class="fs-28 fc-f fw-600">¥</span>
-					<span class="fs-44 fc-f fw-600">19.5</span>
+					<span class="fs-44 fc-f fw-600">{{cardData.total_price||0}}</span>
 				</view>
 				<view class="text-align-center box-2 fs-32 fc-f fw-600" @click="toSave()">立即支付</view>
 			</view>
@@ -127,11 +127,17 @@
 		<Coupon ref="coupon" @giveCouPon='giveCouPon'></Coupon>
 		<SelectAddress ref="selectAddress" @giveAddress='giveAddress'></SelectAddress>
 		<Time ref="selectTime" @giveTime='giveTime'></Time>
-		<EditCode ref='editCode' v-model="codeList"></EditCode>
+		<EditCode ref='editCode' v-model="fromData.pickup_code"></EditCode>
 	</view>
 </template>
 
 <script>
+	import {getExpressCoupon,getExpressCreate,getExpressPay} from '@/api/express.js';
+	import {getAddressDefault} from '@/api/member.js'
+	import {getShopIngList} from '@/api/shopping.js'
+	
+	
+	import tools from "@/service/tools";
 	import Coupon from './confirm-mod/coupon.vue';
 	import SelectAddress from './confirm-mod/select-address.vue';
 	import Time from './confirm-mod/time.vue';
@@ -141,24 +147,89 @@
 		components:{Coupon,SelectAddress,Time,EditCode},
 		data(){
 			return{
+				type:2,//1外卖 2代取 3干洗
 				fromData:{
-					is_default:0,
+					school_id:'',
+					site_id:'',
+					
+					address_id:'',
+					coupon_id:'',
+					note:'',
+					// is_default:0,
+					pickup_code:[],
 				},
-				codeList:['1-3-3344','1-1-3344','12-11-3344','11-11-3344','1-3-3344','1-1-3344','12-11-3344','11-11-3344'],
+				addressData:{},
+				
+				quanInfo:{
+					
+				},
+				quanData:{
+					coupon:[],//可用
+					receive:[],//可领
+				},
+				
+				cardData:{
+					goods_list:[],
+				},
+				
+				isAJAX:false,
 			}
 		},
 		onLoad(e) {
-			
+			this.type = Number(e.type)
+			if(e.pickup_code){
+				this.fromData.pickup_code = e.pickup_code.split(',').map(String)
+				console.log(this.fromData.pickup_code);
+				this.getCard();
+			}
+			this.getAddressDefault();
+			this.getExpressCoupon();
 		},
 		methods:{
+			// 获取购物车
+			getCard(){
+				getShopIngList({type:this.type}).then((res)=>{
+					if(res.code === 1){
+						this.cardData = res.data;
+					}
+				})
+			},
+			// 获取优惠券
+			getExpressCoupon(){
+				let operate_id = uni.getStorageSync('operate_id');
+				getExpressCoupon({operate_id:operate_id}).then((res)=>{
+					if(res.code === 1){
+						this.quanData = res.data;
+					}
+				})
+			},
+			// 获取默认地址
+			getAddressDefault(){
+				getAddressDefault().then((res)=>{
+					if(res.code === 1){
+						this.addressData = res.data
+						if(this.addressData.id){
+							this.fromData.address_id = this.addressData.id;
+						}
+					}
+				})
+			},
+			
 			selectFun(type){
 				if(type === 1){
+					// 选择优惠券
 					this.$refs.coupon.getList();
 				}else if(type === 2){
+					// 选择地址
+					if(this.addressData.id){
+						this.$refs.selectAddress.id = this.addressData.id;
+					}
 					this.$refs.selectAddress.getList();
 				}else if(type === 3){
+					// 选择时间
 					this.$refs.selectTime.getList();
 				}else if(type === 4){
+					// 编辑code
 					this.$refs.editCode.getList();
 				}
 			},
@@ -166,13 +237,53 @@
 				console.log(e);
 			},
 			giveAddress(e){
-				console.log(e);
+				this.addressData = e;
+				this.fromData.address_id = this.addressData.id;
 			},
 			giveTime(e){
 				console.log(e);
 			},
 			toSave(){
-				console.log(this.codeList);
+				if(!this.fromData.address_id){
+					return tools.error('请先选择地址')
+				}
+				
+				if(this.isAJAX){
+					return
+				}
+				this.isAJAX = true;
+				this.fromData.school_id = uni.getStorageSync('school_id');
+				this.fromData.site_id = uni.getStorageSync('site_id');
+				
+				getExpressCreate(this.fromData).then((res)=>{
+					if(res.code === 1){
+						getExpressPay({order_id:res.data.order_id}).then((ret)=>{
+							if(ret.code === 1){
+								uni.requestPayment({
+								  provider: "wxpay", //支付类型-固定值
+								  timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
+								  nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
+								  package: ret.data.wx_pay.package, // 固定值
+								  signType: ret.data.wx_pay.signType, //固定值
+								  paySign: ret.data.wx_pay.paySign, //签名
+								  success: (ren) => {
+								    tools.success("支付成功");
+									this.isAJAX = false;
+									setTimeout(()=>{
+										uni.switchTab({
+											url:"/pages/index/index"
+										})
+									},1500)
+								  },
+								  fail: (err) =>{
+									  this.isAJAX = false;
+								    tools.error("支付失败");
+								  },
+								});
+							}
+						})
+					}
+				})
 			},
 		},
 	}

+ 96 - 32
pages-takeout/replace-take.vue

@@ -51,9 +51,9 @@
 								<span class="fw-400 fc-9 fs-24">/份</span>
 							</view>
 							<view class="display-flex align-items-center">
-								<view class="right-only-right-red fw-500 text-align-center fs-36 fc-f" @click="redNumber(item)">-</view>
-								<view class="right-only-right-2 text-align-center fs-28 fw-400">{{item.num}}</view>
-								<view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" @click="addNumber(item)">+</view>
+								<view v-if="item.number > 0" class="right-only-right-red fw-500 text-align-center fs-36 fc-f" @click="redNumber(1,item)">-</view>
+								<view v-if="item.number > 0" class="right-only-right-2 text-align-center fs-28 fw-400">{{item.number}}</view>
+								<view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" @click="addNumber(1,item)">+</view>
 							</view>
 						</view>
 					</view>
@@ -68,15 +68,15 @@
 			</view>
 		</view>
 		
-		<view class="shop-buttom-money box-border-box" @click="openBuyCrad()">
+		<view class="shop-buttom-money box-border-box" >
 			<view class="shop-buttom-money-1 flex-justify-space align-items-center">
-				<image src="@/static/img/takeout/buy-icon.png" mode="scaleToFill"></image>
-				<view class="shop-buttom-num fs-24 fc-f text-align-center">{{cardData.total_num}}</view>
-				<view class="">
+				<image src="@/static/img/takeout/buy-icon.png" mode="scaleToFill" @click="openBuyCrad()"></image>
+				<view class="shop-buttom-num fs-24 fc-f text-align-center" @click="openBuyCrad()">{{cardData.total_num}}</view>
+				<view class="" @click="openBuyCrad()">
 					<span class="fw-600 fs-24 fc-f">¥</span>
 					<span class="fw-600 fs-44 fc-f">{{cardData.total_price||0}}</span>
 				</view>
-				<view class="shop-buttom-money-2 text-align-center fs-32 fc-f fw-600">去结算</view>
+				<view class="shop-buttom-money-2 text-align-center fs-32 fc-f fw-600" @click="createOrder()">去结算</view>
 			</view>
 		</view>
 		
@@ -96,21 +96,21 @@
 					</view>
 				</view>
 				<view class="scroll-view-css box-border-box p-32">
-					<view class="buy-card-item display-flex" v-for="(item,i) in 5" :key="i">
-						<image src="@/static/img/my/bg.png" mode="scaleToFill"></image>
+					<view class="buy-card-item display-flex" v-for="(item,i) in cardData.goods_list" :key="i">
+						<image :src="item.serve_image" mode="aspectFill"></image>
 						<view class="flex-1">
-							<view class="w-514 text-overflow-ellipsis-one fs-34 fw-600 mb-12">[畅销款]奥尔1良烤肉牛油拌饭拌饭[畅销款]奥尔1良烤肉牛油拌饭拌饭</view>
-							<view class="w-514 text-overflow-ellipsis-one fs-24 fw-400 fc-9 mb-18">不辣,加辣</view>
+							<view class="w-514 text-overflow-ellipsis-one fs-34 fw-600 mb-12">{{item.serve_name}}</view>
+							<view class="w-514 text-overflow-ellipsis-one fs-24 fw-400 fc-9 mb-18">{{item.serve_desc}}</view>
 							
 							<view class="flex-justify-space">
 								<view class="">
 									<span class="fs-24 fc-FB3D03 fw-400">¥</span>
-									<span class="fs-40 fc-FB3D03 fw-b">3.99</span>
+									<span class="fs-40 fc-FB3D03 fw-b">{{item.price}}</span>
 								</view>
 								<view class="display-flex align-items-center">
-									<view class="right-only-right-red fw-500 text-align-center fs-36 fc-f" >-</view>
-									<view class="right-only-right-2 text-align-center fs-28 fw-400">0</view>
-									<view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" >+</view>
+									<view class="right-only-right-red fw-500 text-align-center fs-36 fc-f" @click="redNumber(2,item)">-</view>
+									<view class="right-only-right-2 text-align-center fs-28 fw-400">{{item.number}}</view>
+									<view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" @click="addNumber(2,item)">+</view>
 								</view>
 							</view>
 						</view>
@@ -120,11 +120,11 @@
 				<view class="shop-buttom-money box-border-box" @click="createOrder()">
 					<view class="shop-buttom-money-1 flex-justify-space align-items-center">
 						<image src="@/static/img/takeout/buy-icon.png" mode="scaleToFill"></image>
-						<view class="shop-buttom-num fs-24 fc-f text-align-center">3</view>
+						<view class="shop-buttom-num fs-24 fc-f text-align-center">{{cardData.total_num}}</view>
 						<view class="">
 							<view class="">
 								<span class="fw-600 fs-24 fc-f">¥</span>
-								<span class="fw-600 fs-44 fc-f">19.26</span>
+								<span class="fw-600 fs-44 fc-f">{{cardData.total_price||0}}</span>
 							</view>
 						</view>
 						<view class="shop-buttom-money-2 text-align-center fs-32 fc-f fw-600">去结算</view>
@@ -168,6 +168,14 @@
 			}
 		},
 		onShow() {
+			this.list = [];
+			this.pickup_code = [];
+			this.cardData = {
+				goods_list:[],
+				total_num:0,
+				total_price:0,
+			},
+			
 			this.schoolData.school_id = uni.getStorageSync('school_id');
 			this.schoolData.school_name = uni.getStorageSync('school_name');
 			
@@ -184,7 +192,7 @@
 					if(res.code === 1){
 						this.list = res.data;
 						this.list.forEach((v)=>{
-							v.num = 0
+							v.number = 0
 						})
 						this.getCard();
 					}
@@ -198,7 +206,9 @@
 							this.cardData.goods_list.forEach(v=>{
 								this.list.forEach(t=>{
 									if(v.goods_id === t.id){
-										t.num = v.number
+										t.number = v.number
+									}else{
+										t.number = 0
 									}
 								})
 							})
@@ -206,7 +216,32 @@
 								let obj = {code:''};
 								this.pickup_code.push(obj);
 							}
-							console.log(this.pickup_code);
+						}else{
+							this.list.forEach(t=>{
+								t.number = 0;
+							})
+						}
+					}
+				})
+			},
+			resetCard(){
+				getShopIngList({type:2}).then((res)=>{
+					if(res.code === 1){
+						this.cardData = res.data;
+						if(this.cardData.total_num > 0){
+							this.cardData.goods_list.forEach(v=>{
+								this.list.forEach(t=>{
+									if(v.goods_id === t.id){
+										t.number = v.number
+									}else{
+										t.number = 0
+									}
+								})
+							})
+						}else{
+							this.list.forEach(t=>{
+								t.number = 0;
+							})
 						}
 					}
 				})
@@ -220,40 +255,62 @@
 				})
 			},
 			openBuyCrad(){
-				console.log(this.pickup_code);
-				// this.$refs.popupBuy.open()
+				if(!this.addressData.site_id){
+					tools.error('请选择站点')
+				}else{
+					this.$refs.popupBuy.open()
+				}
 			},
 			createOrder(){
-				
+				let flag = this.pickup_code.every((item)=>{return item.code});
+				if(flag){
+					let arr = [];
+					this.pickup_code.forEach((v)=>{
+						arr.push(v.code)
+					})
+					let pickup_code = arr.join(',')
+					uni.navigateTo({
+						url:'pages-takeout/confirm-order?pickup_code=' + pickup_code + '&type=2'
+					})
+				}else{
+					tools.error('请输入取件码')
+				}
 			},
 			
-			addNumber(item){
+			addNumber(type,item){
 				if(this.isAJAX){
 					return
 				}
 				this.isAJAX = true;
-				setShopIngAdd({type:2,goods_id:item.id}).then((res)=>{
+				let id = type == 1?item.id:item.goods_id;
+				setShopIngAdd({type:2,goods_id:id}).then((res)=>{
 					if(res.code === 1){
 						this.isAJAX = false;
-						item.num += 1;
+						item.number += 1;
+						let obj = {code:''};
+						this.pickup_code.push(obj);
 						this.$forceUpdate();
+						this.resetCard();
 					}else{
 						this.isAJAX = false;
 						tools.error('添加操作失败')
 					}
 				})
 			},
-			redNumber(item){
-				if(item.num > 0){
+			redNumber(type,item){
+				if(item.number > 0){
 					if(this.isAJAX){
 						return
 					}
 					this.isAJAX = true;
-					setShopIngNumber({type:2,goods_id:item.id,operation:2}).then((res)=>{
+					let id = type == 1?item.id:item.goods_id;
+					setShopIngNumber({type:2,goods_id:id,operation:2}).then((res)=>{
 						if(res.code === 1){
 							this.isAJAX = false;
-							item.num -= 1;
+							item.number -= 1;
+							this.pickup_code.pop();
 							this.$forceUpdate();
+							this.resetCard();
 						}else{
 							this.isAJAX = false;
 							tools.error('减少操作失败')
@@ -264,7 +321,14 @@
 				}
 			},
 			cardAllDel(){
-				
+				setShopIngDel({type:2}).then((res)=>{
+					if(res.code === 1){
+						this.pickup_code = [];
+						this.getCard();
+					}else{
+						tools.error('清空失败')
+					}
+				})
 			},
 		}
 	}