| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- <template>
- <view>
- <foodItem style="width:100%;" :food="spindexSP" :shuliang="shuliang" :otherPrice="otherPrice" v-on:Ejiajian="jiajian"></foodItem>
- <danxuanlist style="width:100%;" :infolistD="skuGuige" :isedit="false" v-on:ElistDatachange="listDatachange"></danxuanlist>
- <view class="contentInRowL" style="margin-top: 10rpx;margin-left:6%;align-items: center;">
- <text>{{$t('order.beizhu')}}</text>
- <textarea class="textinput" auto-height="true"
- :always-embed='false'
- :adjust-position='true'
- cursor-spacing='30'
- confirm-hold='true'
- confirm-type='done'
- :focus='false'
- maxlength='100'
- v-model='beizhu'
- @confirm='mineSendBT'
- ></textarea>
-
- </view>
- <view style="display: flex;width:88%;margin-left:6%; margin-bottom: 20rpx;">
- <text class="querenBt" @click="jiagouwuche()">{{$t('gouwu.jiarugouwc')}}</text>
- </view>
- <uni-popup ref="bzPop":maskClick="false">
- <view class="contentColumnC" style="width:700rpx;background-color: white;margin-left: 25rpx;border-radius: 10rpx;">
- <view class="contentInRowS" style="width: 90%;margin-top: 16rpx;">
- <text style="color: chocolate;">{{$t('order.quxiao')}}</text>
- <text style="font-weight: bold;">{{$t('order.beizhu')}}</text>
- <text style="color: #00A6FF;" @click="querenBZ">{{$t('comp.queren')}}</text>
- </view>
- <textarea class="textinput" auto-height="true"
- :always-embed='false'
- :adjust-position='true'
- cursor-spacing='30'
- confirm-hold='true'
- confirm-type='done'
- :focus='false'
- maxlength='100'
- v-model='beizhu'
- @confirm='mineSendBT'
- ></textarea>
- <view style="height: 40rpx;"></view>
- </view>
- </uni-popup>
- </view>
- </template>
- <!--
- "shId": 1, //商家id
- "mdId": 1, //门店id
- "amount": 1, //订单合计金额
- "remarks": "", //备注
- "type": 1, //订单类型:0外送,1自取,2堂食
- "delryTime": "", //配送时间
- "food": "" //订单商品
- -->
- <script>
- export default {
- name:"pdPurchase",
- props: {
- food:'',
- mendId:''
- },
- data() {
- return {
- spindexSP:'',
- skuGuige:'',
- shuliang:1,
- otherPrice:0,
- tempsku:'',
- beizhu:'',
- gouwuche:{
- foodlist:[],
- mendid:'',
- userid:'',
- mendname:''
- }
- };
- },
- watch: {
- food(val){
- //console.log(this.food);
- this.spindexSP = this.food;
- this.skuGuige = this.food.shangpin.foodSku;
- this.otherPrice = this.getotherPrice(this.skuGuige);
- this.tempsku = this.gettempSKU(this.skuGuige);
- this.beizhu='';
- this.shuliang = this.food.shuliang==0?1:this.food.shuliang;
- this.$refs.bzPop.close();
- }
- },
- methods: {
- jiagouwuche(){
- this.gengxingouwuche();
- this.$emit('Ejiagouwuche');
- },
-
- gengxingouwuche(){
- if(this.shuliang<1){
- uni.showToast({
- title: this.$t('comp.qingxzsp'),
- icon: 'none',
- duration: 2500
- })
- return;
- }
- var sp = this.food.shangpin;
- var gwc = uni.getStorageSync('gouwuche');
- if(''==gwc||null==gwc||undefined==gwc){
-
- var item={
- "shId":sp.store.userId, //商家id
- "mdId": sp.store.id, //门店id
- "logo":sp.store.logo,
- "posName":sp.store.posName,
- "lat": sp.store.latitude, //
- "lng": sp.store.longitude, //
- "jvli": 0, //
- "freight": 0, //
- "amount": 0, //订单合计金额
- "foodAmount": 0, //商品金额
- "remarks": "", //备注
- "type": 0, //订单类型:0外送,1自取,2堂食
- "zuohao":'',
- "delryTime": "", //配送时间
- "food":[] //订单商品
- }
- this.gouwuche=[];
- this.gouwuche.push(item);
-
- }
- else{
- this.gouwuche = JSON.parse(gwc);
- }
-
- var mark=0;
- for(var i=0;i<this.gouwuche.length;i++){
- var item = this.gouwuche[i];
- if(item.mdId==sp.store.id){
- mark = 1;
- for(var j=0;j<item.food.length;j++){
- var gwf = item.food[j];
- var ask = JSON.stringify(gwf.ask);
- var tempsku = JSON.stringify(this.tempsku);
- if(gwf.id == sp.id &&ask === tempsku){
- item.food[j].number = this.shuliang;
- this.tongjigouwuche();
- return;
- }
- }
- var f={
- "id": sp.id,
- "name": sp.name,
- "image": sp.image,
- "price": sp.price,
- "otherPrice":this.otherPrice,
- "number": this.shuliang,
- "ask": this.tempsku,
- "beizhu":this.beizhu
- }
- item.food.push(f);
- this.gouwuche[i]=item;
- this.tongjigouwuche();
- return;
- }
- }
-
- if(mark==0){
-
- var item={
- "shId":sp.store.userId, //商家id
- "mdId": sp.store.id, //门店id
- "logo":sp.store.logo,
- "posName":sp.store.posName,
- "lat": sp.store.latitude, //
- "lng": sp.store.longitude, //
- "jvli": 0, //
- "freight": 0, //
- "amount": 0, //订单合计金额
- "foodAmount": 0, //商品金额
- "remarks": "", //备注
- "zuohao":'',
- "type": 0, //订单类型:0外送,1自取,2堂食
- "delryTime": "", //配送时间
- "food":[] //订单商品
- }
- var f={
- "id": sp.id,
- "name": sp.name,
- "image": sp.image,
- "price": sp.price,
- "otherPrice":this.otherPrice,
- "number": this.shuliang,
- "ask": this.tempsku,
- "beizhu":this.beizhu
- }
- item.food.push(f);
- this.gouwuche.push(item);
- this.tongjigouwuche();
- }
- },
-
- tongjigouwuche(){
- for(var i=0;i<this.gouwuche.length;i++){
- var item = this.gouwuche[i];
- var goumaijine=0;
- for (var j=0;j<item.food.length;j++) {
- var food = item.food[j];
- var yidongjine=food.number*(parseFloat(food.price)+parseFloat(food.otherPrice));
- goumaijine = goumaijine+yidongjine;
- }
- this.gouwuche[i].foodAmount=goumaijine;
- this.gouwuche[i].amount=goumaijine;
-
- }
- let tgwc = JSON.stringify(this.gouwuche);
- uni.setStorageSync('gouwuche',tgwc);
- },
-
- jiajian(e){
- this.shuliang = this.shuliang+e;
- console.log(this.food);
- },
- listDatachange(listData){
- this.tempsku = this.gettempSKU(listData);
- this.otherPrice = this.getotherPrice(listData);
- //console.log(this.tempsku,this.otherPrice)
- },
- gettempSKU(foodSku){
- var selectsku=[];
- if(''==foodSku||null==foodSku||undefined==foodSku){
- return selectsku;
- }
- for(var i=0;i<foodSku.length;i++){
- if(foodSku[i].objects.length>0){
- for(var j=0;j<foodSku[i].objects.length;j++){
- if(foodSku[i].objects[j].state==1){
- selectsku.push(foodSku[i].objects[j].name);
- }
- }
- }
- }
- return selectsku;
- },
- getotherPrice(foodSku){
- console.log('getotherPrice',foodSku);
- var jiner=0;
- if(''==foodSku||null==foodSku||undefined==foodSku){
- return 0;
- }
- for(var i=0;i<foodSku.length;i++){
- if(foodSku[i].objects.length>0){
- for(var j=0;j<foodSku[i].objects.length;j++){
- if(foodSku[i].objects[j].state==1){
- if(foodSku[i].objects[j].price==0||!foodSku[i].objects[j].price){
- jiner=jiner+0;
- }
- else{
- jiner=jiner+parseFloat(foodSku[i].objects[j].price);
- }
- }
- }
- }
- }
- if(parseFloat(jiner)){
- console.log('111',jiner);
- return parseFloat(jiner);
- }
- else{
- console.log('222',jiner);
- return 0;
- }
- },
- editBeizhu(){
- console.log('11111111')
- this.$refs.bzPop.open('top');
- },
- mineSendBT(){
- console.log(this.beizhu)
- this.$refs.bzPop.close();
- },
- querenBZ(){
- console.log(this.beizhu)
- this.$refs.bzPop.close();
- },
- },
- }
- </script>
- <style>
- .querenBt{
- margin-top: 30rpx;
- width: 100%;
- height: 60rpx;
- line-height: 60rpx;
- padding: 10rpx;
- border-radius: 20rpx;
- border: solid #40AE36;
- border-width: 0px 0px 6rpx 0px;
- text-align: center;
- justify-content: center;
- background-color: #40AE36;
- color: white;
- box-shadow: 0rpx 0rpx 10rpx 0rpx #40AE36;
- }
- .beizhuBt{
- padding: 10rpx 16rpx 10rpx 16rpx;
- color: white;
- border-radius: 8rpx;
- background-color:chocolate;
- }
- .beizhutext{
- color:darkgray;
- font-size: 30rpx;
- margin-left: 30rpx;
- width: 500rpx;
- }
- .textinput{
- margin-left: 8rpx;
- padding-top: 10rpx;
- padding-bottom: 10rpx;
- width: 80%;
- border-radius: 6rpx;
- border: 1rpx solid darkgray;
- font-size: 32upx;
- background-color: white;
- }
- </style>
|