foodxuangou.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view>
  3. <foodItem style="width:100%;" :food="spindexSP" :shuliang="shuliang" :otherPrice="otherPrice" v-on:Ejiajian="jiajian"></foodItem>
  4. <danxuanlist style="width:100%;" :infolistD="skuGuige" :isedit="false" v-on:ElistDatachange="listDatachange"></danxuanlist>
  5. <view class="contentInRowL" style="margin-top: 10rpx;margin-left:6%;align-items: center;">
  6. <text>{{$t('order.beizhu')}}</text>
  7. <textarea class="textinput" auto-height="true"
  8. :always-embed='false'
  9. :adjust-position='true'
  10. cursor-spacing='30'
  11. confirm-hold='true'
  12. confirm-type='done'
  13. :focus='false'
  14. maxlength='100'
  15. v-model='beizhu'
  16. @confirm='mineSendBT'
  17. ></textarea>
  18. </view>
  19. <view style="display: flex;width:88%;margin-left:6%; margin-bottom: 20rpx;">
  20. <label class="querenBt" @click="jiagouwuche()">{{$t('gouwu.jiarugouwc')}}</label>
  21. </view>
  22. <uni-popup ref="bzPop":maskClick="false">
  23. <view class="contentColumnC" style="width:700rpx;background-color: white;margin-left: 25rpx;border-radius: 10rpx;">
  24. <view class="contentInRowS" style="width: 90%;margin-top: 16rpx;">
  25. <text style="color: chocolate;">{{$t('order.quxiao')}}</text>
  26. <text style="font-weight: bold;">{{$t('order.beizhu')}}</text>
  27. <text style="color: #00A6FF;" @click="querenBZ">{{$t('comp.queren')}}</text>
  28. </view>
  29. <textarea class="textinput" auto-height="true"
  30. :always-embed='false'
  31. :adjust-position='true'
  32. cursor-spacing='30'
  33. confirm-hold='true'
  34. confirm-type='done'
  35. :focus='false'
  36. maxlength='100'
  37. v-model='beizhu'
  38. @confirm='mineSendBT'
  39. ></textarea>
  40. <view style="height: 40rpx;"></view>
  41. </view>
  42. </uni-popup>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. name:"foodxuangou",
  48. props: {
  49. food:''
  50. },
  51. data() {
  52. return {
  53. spindexSP:'',
  54. skuGuige:'',
  55. shuliang:1,
  56. otherPrice:0,
  57. tempsku:'',
  58. beizhu:'',
  59. gouwuche:{
  60. foodlist:[],
  61. mendid:'',
  62. userid:'',
  63. mendname:''
  64. }
  65. };
  66. },
  67. watch: {
  68. food(val){
  69. //console.log(this.food);
  70. this.spindexSP = this.food;
  71. this.skuGuige = this.food.shangpin.foodSku;
  72. this.otherPrice = this.getotherPrice(this.skuGuige);
  73. this.tempsku = this.gettempSKU(this.skuGuige);
  74. this.beizhu='';
  75. this.$refs.bzPop.close();
  76. }
  77. },
  78. methods: {
  79. jiagouwuche(){
  80. this.gengxingouwuche();
  81. this.$emit('Ejiagouwuche');
  82. },
  83. gengxingouwuche(){
  84. if(this.shuliang<1){
  85. uni.showToast({
  86. title: this.$t('comp.qingxzsp'),
  87. icon: 'none',
  88. duration: 2500
  89. })
  90. return;
  91. }
  92. var gwc = uni.getStorageSync('gouwuche');
  93. if(''==gwc||null==gwc||undefined==gwc){
  94. this.gouwuche={
  95. foodlist:[],
  96. mendid:'',
  97. userid:'',
  98. mendname:''
  99. };
  100. }
  101. else{
  102. this.gouwuche = JSON.parse(gwc);
  103. }
  104. var sp = this.food.shangpin;
  105. if(this.gouwuche.mendid!=sp.store.id){
  106. this.gouwuche={
  107. foodlist:[],
  108. mendid:sp.store.id,
  109. userid:sp.store.userId,
  110. mendname:sp.store.posName,
  111. };
  112. }
  113. for(var i=0;i<this.gouwuche.foodlist.length;i++){
  114. var gwf = this.gouwuche.foodlist[i];
  115. var ask = JSON.stringify(gwf.ask);
  116. var tempsku = JSON.stringify(this.tempsku);
  117. if(gwf.id == sp.id &&ask === tempsku){
  118. this.gouwuche.foodlist[i].number = this.shuliang;
  119. let sgwc = JSON.stringify(this.gouwuche);
  120. uni.setStorageSync('gouwuche',sgwc);
  121. return;
  122. }
  123. }
  124. var f={
  125. "id": sp.id,
  126. "name": sp.name,
  127. "image": sp.image,
  128. "price": sp.price,
  129. "otherPrice":this.otherPrice,
  130. "number": this.shuliang,
  131. "ask": this.tempsku,
  132. "beizhu":this.beizhu
  133. }
  134. this.gouwuche.foodlist.push(f);
  135. let tgwc = JSON.stringify(this.gouwuche);
  136. uni.setStorageSync('gouwuche',tgwc);
  137. },
  138. jiajian(e){
  139. this.shuliang = this.shuliang+e;
  140. },
  141. listDatachange(listData){
  142. this.tempsku = this.gettempSKU(listData);
  143. this.otherPrice = this.getotherPrice(listData);
  144. //console.log(this.tempsku,this.otherPrice)
  145. },
  146. gettempSKU(foodSku){
  147. var selectsku=[];
  148. if(''==foodSku||null==foodSku||undefined==foodSku){
  149. return selectsku;
  150. }
  151. for(var i=0;i<foodSku.length;i++){
  152. if(foodSku[i].objects.length>0){
  153. for(var j=0;j<foodSku[i].objects.length;j++){
  154. if(foodSku[i].objects[j].state==1){
  155. selectsku.push(foodSku[i].objects[j].name);
  156. }
  157. }
  158. }
  159. }
  160. return selectsku;
  161. },
  162. getotherPrice(foodSku){
  163. console.log('getotherPrice',foodSku);
  164. var jiner=0;
  165. if(''==foodSku||null==foodSku||undefined==foodSku){
  166. return 0;
  167. }
  168. for(var i=0;i<foodSku.length;i++){
  169. if(foodSku[i].objects.length>0){
  170. for(var j=0;j<foodSku[i].objects.length;j++){
  171. if(foodSku[i].objects[j].state==1){
  172. if(foodSku[i].objects[j].price==0||!foodSku[i].objects[j].price){
  173. jiner=jiner+0;
  174. }
  175. else{
  176. jiner=jiner+parseFloat(foodSku[i].objects[j].price);
  177. }
  178. }
  179. }
  180. }
  181. }
  182. if(parseFloat(jiner)){
  183. console.log('111',jiner);
  184. return parseFloat(jiner);
  185. }
  186. else{
  187. console.log('222',jiner);
  188. return 0;
  189. }
  190. },
  191. editBeizhu(){
  192. console.log('11111111')
  193. this.$refs.bzPop.open('top');
  194. },
  195. mineSendBT(){
  196. console.log(this.beizhu)
  197. this.$refs.bzPop.close();
  198. },
  199. querenBZ(){
  200. console.log(this.beizhu)
  201. this.$refs.bzPop.close();
  202. },
  203. },
  204. }
  205. </script>
  206. <style>
  207. .querenBt{
  208. margin-top: 30rpx;
  209. width: 100%;
  210. height: 60rpx;
  211. line-height: 60rpx;
  212. padding: 10rpx;
  213. border-radius: 20rpx;
  214. border: solid #00A6FF;
  215. border-width: 0px 0px 6rpx 0px;
  216. text-align: center;
  217. justify-content: center;
  218. background-color: #00A6FF;
  219. color: white;
  220. box-shadow: 0rpx 0rpx 10rpx 0rpx #00A6FF;
  221. }
  222. .beizhuBt{
  223. padding: 10rpx 16rpx 10rpx 16rpx;
  224. color: white;
  225. border-radius: 8rpx;
  226. background-color:chocolate;
  227. }
  228. .beizhutext{
  229. color:darkgray;
  230. font-size: 30rpx;
  231. margin-left: 30rpx;
  232. width: 500rpx;
  233. }
  234. .textinput{
  235. margin-left: 8rpx;
  236. padding-top: 10rpx;
  237. padding-bottom: 10rpx;
  238. width: 80%;
  239. border-radius: 6rpx;
  240. border: 1rpx solid darkgray;
  241. font-size: 32upx;
  242. background-color: white;
  243. }
  244. </style>