gouwuche.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. }
  81. else{
  82. this.gouwuche = JSON.parse(gwc);
  83. }
  84. this.tongjigouwuche();
  85. },
  86. methods: {
  87. qingkonggouwuc(){
  88. var that = this;
  89. uni.showModal({
  90. title: that.$t('api.message'),
  91. content: that.$t('gouwu.shifouqkgwc'),
  92. cancelText:that.$t('order.quxiao'),
  93. confirmText:that.$t('comp.queren'),
  94. success: function (res) {
  95. if (res.confirm) { //这里是点击了确定以后
  96. uni.setStorageSync('gouwuche','');
  97. that.kongche=true;
  98. that.gouwuche=[];
  99. that.gwbcolor='darkgray';
  100. that.gwbTcolor='black';
  101. that.notext=that.$t('comp.weixgsp');
  102. that.gouwcheimg='/static/meishi/BuyS@3x.png';
  103. that.goumaijine = 0;
  104. } else { //这里是点击了取消以后
  105. console.log('用户点击取消')
  106. }
  107. }
  108. })
  109. },
  110. Rdanjia(price,othprice){
  111. if(!othprice){
  112. othprice=0;
  113. }
  114. return this.$formPr((parseFloat(price)+parseFloat(othprice)));
  115. },
  116. jiangouwuche(indexs,index){
  117. var goumail=this.gouwuche[indexs].food[index].number;
  118. goumail=goumail-1;
  119. if(goumail==0){
  120. this.gouwuche[indexs].food.splice(index,1);
  121. if(this.gouwuche[indexs].food.length==0){
  122. this.gouwuche.splice(indexs,1);
  123. let gwc = JSON.stringify(this.gouwuche);
  124. uni.setStorageSync('gouwuche',gwc);
  125. this.tongjigouwuche();
  126. return;
  127. }
  128. }
  129. else{
  130. this.gouwuche[indexs].food[index].number=goumail;
  131. }
  132. console.log(goumail);
  133. var goumaijine = 0;
  134. for (var j=0;j<this.gouwuche[indexs].food.length;j++) {
  135. var food = this.gouwuche[indexs].food[j];
  136. var yidongjine=food.number*(parseFloat(food.price)+parseFloat(food.otherPrice));
  137. goumaijine = goumaijine+yidongjine;
  138. }
  139. this.gouwuche[indexs].amount=goumaijine;
  140. let gwc = JSON.stringify(this.gouwuche);
  141. uni.setStorageSync('gouwuche',gwc);
  142. this.tongjigouwuche();
  143. },
  144. jiagouwuche(indexs,index){
  145. var goumail=this.gouwuche[indexs].food[index].number;
  146. goumail=goumail+1;
  147. this.gouwuche[indexs].food[index].number=goumail;
  148. console.log(goumail);
  149. var goumaijine = 0;
  150. for (var j=0;j<this.gouwuche[indexs].food.length;j++) {
  151. var food = this.gouwuche[indexs].food[j];
  152. var yidongjine=food.number*(parseFloat(food.price)+parseFloat(food.otherPrice));
  153. goumaijine = goumaijine+yidongjine;
  154. }
  155. this.gouwuche[indexs].amount=goumaijine;
  156. let gwc = JSON.stringify(this.gouwuche);
  157. uni.setStorageSync('gouwuche',gwc);
  158. this.tongjigouwuche();
  159. },
  160. tongjigouwuche(){
  161. this.goumaijine = 0;
  162. for(var i=0;i<this.gouwuche.length;i++){
  163. var item = this.gouwuche[i];
  164. var yidongjine=item.amount;
  165. this.goumaijine = this.goumaijine+yidongjine;
  166. }
  167. if(this.goumaijine>0){
  168. this.notext= this.$formPr(this.goumaijine)+this.$t('locale.huobidw');
  169. console.log(this.notext);
  170. this.gwbcolor='green';
  171. this.gwbTcolor='white';
  172. this.gouwcheimg='/static/meishi/BuyS@3x.png';
  173. }
  174. if(this.goumaijine==0){
  175. this.gwbcolor='darkgray';
  176. this.gwbTcolor='black';
  177. this.notext=this.$t('comp.weixgsp');
  178. this.gouwcheimg='/static/meishi/BuyS@3x.png';
  179. }
  180. },
  181. qujiesuan(){
  182. var that = this;
  183. if(this.goumaijine==0){
  184. uni.showToast({
  185. title: that.$t('comp.qingxzsp'),
  186. icon: 'none',
  187. duration: 2500
  188. })
  189. return;
  190. }
  191. var token = uni.getStorageSync("token");
  192. if(token == '' || token == undefined || token == null){
  193. uni.navigateTo({
  194. url:'/pages/UserCenter/LoginView'
  195. })
  196. return;
  197. }
  198. uni.navigateTo({
  199. url:'/pages/OrderList/buy/dingdanjiesuan'
  200. })
  201. },
  202. }
  203. }
  204. </script>
  205. <style>
  206. page{
  207. background-color: #F2F3F7;
  208. }
  209. .contentV{
  210. width:94%;
  211. margin-left: 3%;
  212. background-color: white;
  213. }
  214. .viewinrow{
  215. display: flex;
  216. flex-direction: row;
  217. align-items: center;
  218. }
  219. .touyuan{
  220. width: 40rpx;
  221. }
  222. .viewpading{
  223. padding: 3%;
  224. width:94%;
  225. }
  226. .actBTV{
  227. display: flex;
  228. flex-direction: row;
  229. justify-content:space-between;
  230. align-items: center;
  231. }
  232. .spnodetail{
  233. display: flex;
  234. flex-direction: row;
  235. align-items: center;
  236. background-color: white;
  237. border-bottom: 2rpx solid lightgray;
  238. }
  239. .spIcon{
  240. margin: 20rpx;
  241. width: 90rpx;
  242. height: 90rpx;
  243. }
  244. .xiaoji{
  245. margin-left: auto;
  246. margin-right: 30rpx;
  247. }
  248. .keywordLct{
  249. display: flex;
  250. flex-wrap: wrap;
  251. justify-content:flex-start;
  252. align-items:center;
  253. }
  254. .kouweisku{
  255. padding:0rpx 4rpx 0rpx 4rpx;
  256. margin-right: 6rpx;
  257. margin-top: 6rpx;
  258. margin-bottom: 4rpx;
  259. font-size: 26rpx;
  260. text-align: center;
  261. box-sizing: border-box;
  262. border: 2rpx solid lightgray;
  263. border-radius: 30rpx;
  264. color: orangered;
  265. }
  266. .imageRJ{
  267. width: 40rpx;
  268. height: 40rpx;
  269. margin-right: 8rpx;
  270. }
  271. .imageR{
  272. width: 40rpx;
  273. height: 40rpx;
  274. margin-right: 30rpx;
  275. }
  276. .textR{
  277. font-size: 26rpx;
  278. margin-left: 6rpx;
  279. margin-right: 6rpx;
  280. }
  281. .bottomfloatV{
  282. position: fixed;
  283. flex-direction: row;
  284. align-items: center;
  285. left: 0;
  286. right: 0;
  287. bottom: 0;
  288. z-index: 999;
  289. background-color: whitesmoke;
  290. height: 120rpx;
  291. }
  292. .buyBT{
  293. display:flex;
  294. flex-direction: row;
  295. justify-content:flex-start;
  296. align-items: center;
  297. margin-top: 20rpx;
  298. width:100%;
  299. }
  300. .peisongsuoming{
  301. font-size: 26rpx;
  302. line-height: 38rpx;
  303. height: 38rpx;
  304. color: dimgray;
  305. }
  306. .gouwuche{
  307. margin-left: 20rpx;
  308. width: 80rpx;
  309. height: 80rpx;
  310. }
  311. .qjs{
  312. border-radius: 30rpx;
  313. padding-left: 26rpx;
  314. padding-right: 26rpx;
  315. margin-left: auto;
  316. margin-right: 30rpx;
  317. font-size: 32rpx;
  318. height: 60rpx;
  319. line-height: 60rpx;
  320. }
  321. </style>