gouwuche.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="contentV">
  3. <customNav :shownav="false" :title="$t('gouwu.gouwuche')" titledetl=""></customNav>
  4. <view v-if="!kongche" class="actBTV viewpading">
  5. <view >
  6. <image class="touyuan" src="/static/meishi/BuyS@3x.png" mode="widthFix"></image>
  7. <text style="margin-left: 20rpx;">{{gouwuche.mendname}}</text>
  8. </view>
  9. <image class="touyuan" src="/static/images/sanchu@3x.png" mode="widthFix" @click="qingkonggouwuc"></image>
  10. </view>
  11. <view v-if="kongche" class="actBTV" style="height: 80rpx;padding-top:40rpx;background-color: whitesmoke">
  12. <view class="">
  13. <image class="touyuan" src="/static/meishi/BuyS@3x.png" mode="widthFix"></image>
  14. <text style="margin-left: 20rpx;">{{$t('gouwu.gwckongong')}}</text>
  15. </view>
  16. </view>
  17. <view>
  18. <view v-for="(items,indexs) in gouwuche">
  19. <view class="contentInRowL" style="align-items: center;">
  20. <netImage style="margin-left: 12rpx;margin-top: 10rpx;" width="60" height="60" bradius="30" :mysrc="items.logo" mymode="scaleToFill"></netImage>
  21. <text style="padding-left: 10rpx;">{{items.posName}}</text>
  22. </view>
  23. <view v-for="(item,index) in items.food">
  24. <view class="spnodetail">
  25. <view class="">
  26. <myImage class="spIcon" :mysrc="item.image" mymode="scaleToFill"></myImage>
  27. </view>
  28. <view style="width: 100%;">
  29. <view class="actBTV">
  30. <view style="font-size: 30rpx;">{{item.name}}</view>
  31. </view>
  32. <view class="keywordLct" >
  33. <view class="kouweisku" v-for="sku in item.ask">{{sku}}</view>
  34. </view>
  35. <view class="contentInRowS" style="margin-bottom: 8rpx;">
  36. <view style="font-size: 26rpx;color: blueviolet;margin-right: 10rpx;">{{$t('shangpin.shoujia')}}: {{Rdanjia(item.price,item.otherPrice)}}{{$t('locale.huobidw')}}</view>
  37. <view class="viewinrow" >
  38. <image v-if="item.number>0" class="imageRJ" src="/static/meishi/jianh.png" mode="aspectFit" @click="jiangouwuche(indexs,index)"></image>
  39. <text v-if="item.number>0" class="textR">{{item.number}}</text>
  40. <image class="imageR" src="/static/meishi/jiah.png" mode="aspectFit" @click="jiagouwuche(indexs,index)"></image>
  41. </view>
  42. </view>
  43. <view v-if="item.beizhu" class="">
  44. <text style="font-size: 30rpx;color:#00A6FF;">{{item.beizhu}}</text>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="bottomfloatV">
  52. <view class="buyBT" >
  53. <image class="gouwuche" :src="gouwcheimg" mode="aspectFit"></image>
  54. <label class="peisongsuoming">{{notext}}</label>
  55. <label class="qjs" :style="{backgroundColor:gwbcolor,color:gwbTcolor}" @click="qujiesuan">{{$t('comp.qujiesuan')}}</label>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. gouwuche:[],
  65. gwbcolor:'darkgray',
  66. gwbTcolor:'black',
  67. gouwcheimg:'/static/meishi/BuyS@3x.png',
  68. notext:this.$t('comp.weixgsp'),
  69. goumaijine:0,
  70. kongche:false
  71. }
  72. },
  73. onShow() {
  74. this.kongche=false;
  75. var gwc = uni.getStorageSync('gouwuche');
  76. if(''==gwc||null==gwc||undefined==gwc){
  77. this.kongche=true;
  78. this.gouwuche=[];
  79. console.log('!!!!!!!!!!!!!:',this.gouwuche);
  80. return
  81. }
  82. else{
  83. this.gouwuche = JSON.parse(gwc);
  84. }
  85. this.tongjigouwuche();
  86. },
  87. methods: {
  88. qingkonggouwuc(){
  89. var that = this;
  90. uni.showModal({
  91. title: that.$t('api.message'),
  92. content: that.$t('gouwu.shifouqkgwc'),
  93. cancelText:that.$t('order.quxiao'),
  94. confirmText:that.$t('comp.queren'),
  95. success: function (res) {
  96. if (res.confirm) { //这里是点击了确定以后
  97. uni.setStorageSync('gouwuche','');
  98. that.kongche=true;
  99. that.gouwuche=[];
  100. that.gwbcolor='darkgray';
  101. that.gwbTcolor='black';
  102. that.notext=that.$t('comp.weixgsp');
  103. that.gouwcheimg='/static/meishi/BuyS@3x.png';
  104. that.goumaijine = 0;
  105. } else { //这里是点击了取消以后
  106. console.log('用户点击取消')
  107. }
  108. }
  109. })
  110. },
  111. Rdanjia(price,othprice){
  112. if(!othprice){
  113. othprice=0;
  114. }
  115. return this.$formPr((parseFloat(price)+parseFloat(othprice)));
  116. },
  117. jiangouwuche(indexs,index){
  118. var goumail=this.gouwuche[indexs].food[index].number;
  119. goumail=goumail-1;
  120. if(goumail==0){
  121. this.gouwuche[indexs].food.splice(index,1);
  122. if(this.gouwuche[indexs].food.length==0){
  123. this.gouwuche.splice(indexs,1);
  124. let gwc = JSON.stringify(this.gouwuche);
  125. uni.setStorageSync('gouwuche',gwc);
  126. this.tongjigouwuche();
  127. return;
  128. }
  129. }
  130. else{
  131. this.gouwuche[indexs].food[index].number=goumail;
  132. }
  133. console.log(goumail);
  134. var goumaijine = 0;
  135. for (var j=0;j<this.gouwuche[indexs].food.length;j++) {
  136. var food = this.gouwuche[indexs].food[j];
  137. var yidongjine=food.number*(parseFloat(food.price)+parseFloat(food.otherPrice));
  138. goumaijine = goumaijine+yidongjine;
  139. }
  140. this.gouwuche[indexs].amount=goumaijine;
  141. let gwc = JSON.stringify(this.gouwuche);
  142. uni.setStorageSync('gouwuche',gwc);
  143. this.tongjigouwuche();
  144. },
  145. jiagouwuche(indexs,index){
  146. var goumail=this.gouwuche[indexs].food[index].number;
  147. goumail=goumail+1;
  148. this.gouwuche[indexs].food[index].number=goumail;
  149. console.log(goumail);
  150. var goumaijine = 0;
  151. for (var j=0;j<this.gouwuche[indexs].food.length;j++) {
  152. var food = this.gouwuche[indexs].food[j];
  153. var yidongjine=food.number*(parseFloat(food.price)+parseFloat(food.otherPrice));
  154. goumaijine = goumaijine+yidongjine;
  155. }
  156. this.gouwuche[indexs].amount=goumaijine;
  157. let gwc = JSON.stringify(this.gouwuche);
  158. uni.setStorageSync('gouwuche',gwc);
  159. this.tongjigouwuche();
  160. },
  161. tongjigouwuche(){
  162. this.goumaijine = 0;
  163. for(var i=0;i<this.gouwuche.length;i++){
  164. var item = this.gouwuche[i];
  165. var yidongjine=item.amount;
  166. this.goumaijine = this.goumaijine+yidongjine;
  167. }
  168. if(this.goumaijine>0){
  169. this.notext= this.$formPr(this.goumaijine)+this.$t('locale.huobidw');
  170. console.log(this.notext);
  171. this.gwbcolor='green';
  172. this.gwbTcolor='white';
  173. this.gouwcheimg='/static/meishi/BuyS@3x.png';
  174. }
  175. if(this.goumaijine==0){
  176. this.gwbcolor='darkgray';
  177. this.gwbTcolor='black';
  178. this.notext=this.$t('comp.weixgsp');
  179. this.gouwcheimg='/static/meishi/BuyS@3x.png';
  180. }
  181. },
  182. qujiesuan(){
  183. var that = this;
  184. if(this.goumaijine==0){
  185. uni.showToast({
  186. title: that.$t('comp.qingxzsp'),
  187. icon: 'none',
  188. duration: 2500
  189. })
  190. return;
  191. }
  192. var token = uni.getStorageSync("token");
  193. if(token == '' || token == undefined || token == null){
  194. uni.navigateTo({
  195. url:'/pages/UserCenter/LoginView'
  196. })
  197. return;
  198. }
  199. uni.navigateTo({
  200. url:'/pages/OrderList/buy/dingdanjiesuan'
  201. })
  202. },
  203. }
  204. }
  205. </script>
  206. <style>
  207. page{
  208. background-color: #F2F3F7;
  209. }
  210. .contentV{
  211. width:94%;
  212. margin-left: 3%;
  213. background-color: white;
  214. }
  215. .viewinrow{
  216. display: flex;
  217. flex-direction: row;
  218. align-items: center;
  219. }
  220. .touyuan{
  221. width: 40rpx;
  222. }
  223. .viewpading{
  224. padding: 3%;
  225. width:94%;
  226. }
  227. .actBTV{
  228. display: flex;
  229. flex-direction: row;
  230. justify-content:space-between;
  231. align-items: center;
  232. }
  233. .spnodetail{
  234. display: flex;
  235. flex-direction: row;
  236. align-items: center;
  237. background-color: white;
  238. border-bottom: 2rpx solid lightgray;
  239. }
  240. .spIcon{
  241. margin: 20rpx;
  242. width: 90rpx;
  243. height: 90rpx;
  244. }
  245. .xiaoji{
  246. margin-left: auto;
  247. margin-right: 30rpx;
  248. }
  249. .keywordLct{
  250. display: flex;
  251. flex-wrap: wrap;
  252. justify-content:flex-start;
  253. align-items:center;
  254. }
  255. .kouweisku{
  256. padding:0rpx 4rpx 0rpx 4rpx;
  257. margin-right: 6rpx;
  258. margin-top: 6rpx;
  259. margin-bottom: 4rpx;
  260. font-size: 26rpx;
  261. text-align: center;
  262. box-sizing: border-box;
  263. border: 2rpx solid lightgray;
  264. border-radius: 30rpx;
  265. color: orangered;
  266. }
  267. .imageRJ{
  268. width: 40rpx;
  269. height: 40rpx;
  270. margin-right: 8rpx;
  271. }
  272. .imageR{
  273. width: 40rpx;
  274. height: 40rpx;
  275. margin-right: 30rpx;
  276. }
  277. .textR{
  278. font-size: 26rpx;
  279. margin-left: 6rpx;
  280. margin-right: 6rpx;
  281. }
  282. .bottomfloatV{
  283. position: fixed;
  284. flex-direction: row;
  285. align-items: center;
  286. left: 0;
  287. right: 0;
  288. bottom: 0;
  289. z-index: 999;
  290. background-color: whitesmoke;
  291. height: 120rpx;
  292. }
  293. .buyBT{
  294. display:flex;
  295. flex-direction: row;
  296. justify-content:flex-start;
  297. align-items: center;
  298. margin-top: 20rpx;
  299. width:100%;
  300. }
  301. .peisongsuoming{
  302. font-size: 26rpx;
  303. line-height: 38rpx;
  304. height: 38rpx;
  305. color: dimgray;
  306. }
  307. .gouwuche{
  308. margin-left: 20rpx;
  309. width: 80rpx;
  310. height: 80rpx;
  311. }
  312. .qjs{
  313. border-radius: 30rpx;
  314. padding-left: 26rpx;
  315. padding-right: 26rpx;
  316. margin-left: auto;
  317. margin-right: 30rpx;
  318. font-size: 32rpx;
  319. height: 60rpx;
  320. line-height: 60rpx;
  321. }
  322. </style>