gouwuche.vue 8.6 KB

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