shangpinxiangqing.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="$t('index.goodsxq')" titledetl=""></customNav>
  4. <view class="contentColumn">
  5. <view>
  6. <!--<myImage class="imageV" :mysrc="shangpinImage" mymode="widthFix"></myImage>-->
  7. <image class="imageV" :src="shangpinImage" mode="scaleToFill" @error="imageError()"></image>
  8. </view>
  9. <view class="contentColumn" style="margin-left: 4%;width: 92%;">
  10. <view class="dianpuming">
  11. <text>{{shangpinxq.name}}</text>
  12. </view>
  13. </view>
  14. <view class="contentInRowS" style="margin-left: 4%;width: 92%;">
  15. <view class="">
  16. <text class="peisongsuoming">{{$formPr(shangpinxq.price)}}{{$t('locale.huobidw')}}</text>
  17. </view>
  18. <view v-if="shangpinxq.stackingUp==0" class="rconten">
  19. <image v-if="showbt" class="imageRJ" src="/static/images/jian@3x.png" mode="aspectFit" @click="jiangouwuche"></image>
  20. <text v-if="showbt" class="textR">{{goumail}}</text>
  21. <image class="imageR" src="/static/images/plus-circle-fill@3x.png" mode="aspectFit" @click="editSKU"></image>
  22. </view>
  23. <view v-if="shangpinxq.stackingUp==1" class="rconten">
  24. <text class="textR">{{$t('mend.yixiajia')}}</text>
  25. </view>
  26. </view>
  27. <!-- <danxuanlist style="width:100%;" :infolistD="infosku" :isedit="false" v-on:ElistDatachange="listDatachange"></danxuanlist> -->
  28. <view class="">
  29. <text class="xsxqt">{{$t('index.goodsxq')}}:</text>
  30. </view>
  31. <view class="contentColumn shangpinwenmiao">
  32. <text>{{shangpinxq.introduce}}</text>
  33. </view>
  34. </view>
  35. <view style="height: 170rpx;"></view>
  36. <view class="bottomfloatV">
  37. <view class="buyBT" @click="qujiesuan">
  38. <image class="gouwuche" :src="gouwcheimg" mode="aspectFit"></image>
  39. <text class="peisongsuoming">{{notext}}</text>
  40. <text class="qjs" :style="{backgroundColor:gwbcolor,color:gwbTcolor}">{{$t('comp.lijigoumai')}}</text>
  41. </view>
  42. </view>
  43. <popViewGG :show="showpop" :showbotom="false" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
  44. <foodxuangou style="width:100%;" :food="spindexSP" v-on:Ejiagouwuche="jiagouwuche"></foodxuangou>
  45. </popViewGG>
  46. </view>
  47. </template>
  48. <script>
  49. import api from "@/pages/api/api.js"
  50. export default {
  51. data() {
  52. return {
  53. goumail:0,
  54. goumaijine:0,
  55. notext:this.$t('comp.weixgsp'),
  56. gwbcolor:'darkgray',
  57. gwbTcolor:'black',
  58. gouwcheimg:'/static/images/gouwuh@3x.png',
  59. showbt:false,
  60. id:1,
  61. isShangjia:0,
  62. spindexSP:'',
  63. shangpinxq:[],
  64. shangpinImage:'',
  65. infosku:'',
  66. showpop:false,
  67. sku:[],
  68. selectsku:[],
  69. gouwuche:{
  70. foodlist:[],
  71. mendid:'',
  72. userId:'',
  73. mendname:''
  74. }
  75. }
  76. },
  77. onLoad(option) {
  78. this.id=option.id;
  79. this.isShangjia=option.isShangjia;
  80. },
  81. onShow() {
  82. var gwc = uni.getStorageSync('gouwuche');
  83. if(''==gwc||null==gwc||undefined==gwc){
  84. this.goumail = 0;
  85. this.gouwuche={
  86. foodlist:[],
  87. mendid:'',
  88. userid:'',
  89. mendname:''
  90. };
  91. }
  92. else{
  93. this.gouwuche = JSON.parse(gwc);
  94. }
  95. this.jinerpand();
  96. this.getGoodsDetail(this.id);
  97. if(1!=this.isShangjia){
  98. var webView = this.$mp.page.$getAppWebview();
  99. webView.setTitleNViewButtonStyle(0,{
  100. width: '0'
  101. });
  102. }
  103. },
  104. methods: {
  105. editSKU(index){
  106. var tempsp={
  107. "shangpin":this.shangpinxq,
  108. "sku":'',
  109. "otherPrice":'',
  110. "shuliang":0
  111. }
  112. this.spindexSP = tempsp;
  113. this.showpop=true;
  114. //this.$refs.popup.open();
  115. },
  116. jiagouwuche(){
  117. var gwc = uni.getStorageSync('gouwuche');
  118. if(''==gwc||null==gwc||undefined==gwc){
  119. this.gouwuche={
  120. foodlist:[],
  121. mendid:'',
  122. userid:'',
  123. mendname:''
  124. };
  125. }
  126. else{
  127. this.gouwuche = JSON.parse(gwc);
  128. }
  129. this.tongjigouwuche();
  130. this.showpop=false;
  131. },
  132. chooseCancel(){
  133. this.showpop=false;
  134. },
  135. jiangouwuche(){
  136. //跳转购物车
  137. uni.navigateTo({
  138. url:'/pages/OrderList/buy/gouwuche'
  139. })
  140. },
  141. tongjigouwuche(){
  142. this.goumail = 0;
  143. this.goumaijine = 0;
  144. if(this.gouwuche.mendid==this.shangpinxq.store.id){
  145. for(var j=0;j<this.gouwuche.foodlist.length;j++){
  146. var sp = this.gouwuche.foodlist[j];
  147. if(sp.id==this.shangpinxq.id){
  148. this.goumaijine = this.goumaijine + sp.number*(sp.price+sp.otherPrice);
  149. this.goumail = this.goumail + sp.number;
  150. }
  151. }
  152. }
  153. this.jinerpand();
  154. },
  155. jinerpand(){
  156. console.log('jinerpand',this.goumail)
  157. if(this.goumail>0){
  158. this.gwbcolor='green';
  159. this.gwbTcolor='white';
  160. this.notext=this.$formPr(this.goumaijine)+this.$t('locale.huobidw');
  161. this.gouwcheimg='/static/images/gouwu@3x.png';
  162. this.showbt=true;
  163. }
  164. else{
  165. this.gwbcolor='darkgray';
  166. this.gwbTcolor='black';
  167. this.notext=this.$t('comp.weixgsp');
  168. this.gouwcheimg='/static/images/gouwuh@3x.png';
  169. this.showbt=false;
  170. }
  171. },
  172. qujiesuan(){
  173. if(this.shangpinxq.store.state==1){
  174. uni.showToast({
  175. title: this.$t('mend.statedy'),
  176. icon: 'none',
  177. duration: 2500
  178. })
  179. return;
  180. }
  181. var that = this;
  182. if(!this.showbt){
  183. uni.showToast({
  184. title: that.$t('comp.qingxzsp'),
  185. icon: 'none',
  186. duration: 3500
  187. })
  188. return;
  189. }
  190. var token = uni.getStorageSync("token");
  191. if(token == '' || token == undefined || token == null){
  192. uni.navigateTo({
  193. url:'/pages/UserCenter/LoginView'
  194. })
  195. return;
  196. }
  197. var foodlist=[];
  198. if(this.gouwuche.mendid==this.shangpinxq.store.id){
  199. for(var j=0;j<this.gouwuche.foodlist.length;j++){
  200. var sp = this.gouwuche.foodlist[j];
  201. if(sp.id==this.shangpinxq.id){
  202. foodlist.push(sp);
  203. }
  204. }
  205. }
  206. uni.setStorageSync('JSfoodlist',foodlist);
  207. uni.navigateTo({
  208. url:'/pages/OrderList/buy/jiesuanYe?mendid='+this.shangpinxq.store.id+'&userid='+this.shangpinxq.store.userId
  209. })
  210. },
  211. getGoodsDetail(id){
  212. api('GoodsDetail',{
  213. id:id
  214. },r=>{
  215. this.shangpinxq=r.data.data;
  216. console.log(this.shangpinxq);
  217. this.shangpinImage=this.$baseImagurl + this.shangpinxq.image;
  218. this.tongjigouwuche();
  219. },failc=>{
  220. //console.log('getadvertis----',failc)
  221. })
  222. },
  223. imageError(){
  224. this.shangpinImage = '/static/logo.png';//默认图片
  225. },
  226. }
  227. }
  228. </script>
  229. <style lang="scss">
  230. .imageV{
  231. width:750rpx;
  232. height: 750rpx;
  233. background-color:floralwhite;
  234. }
  235. .imageZ{
  236. width: 30rpx;
  237. height: 30rpx;
  238. }
  239. .imageRJ{
  240. width: 56rpx;
  241. height: 56rpx;
  242. margin-right: 8rpx;
  243. }
  244. .imageR{
  245. width: 56rpx;
  246. height: 56rpx;
  247. margin-right: 0rpx;
  248. }
  249. .textR{
  250. margin-left: 6rpx;
  251. margin-right: 6rpx;
  252. }
  253. .msText{
  254. width:92%;
  255. margin-top: 20rpx;
  256. margin-left: 4%;
  257. text-align: left;
  258. }
  259. .contensb{
  260. display: flex;
  261. flex-direction: row;
  262. justify-content:space-between;
  263. align-items: center;
  264. }
  265. .rconten{
  266. margin-left: auto;
  267. display:flex;
  268. flex-direction: row;
  269. align-items: center;
  270. }
  271. .buyBT{
  272. display:flex;
  273. flex-direction: row;
  274. justify-content:flex-start;
  275. align-items: center;
  276. width:100%;
  277. }
  278. .dianpuming{
  279. font-size: 30rpx;
  280. line-height: 32rpx;
  281. font-weight: bold;
  282. }
  283. .peisongsuoming{
  284. font-size: 26rpx;
  285. line-height: 32rpx;
  286. color: dimgray;
  287. }
  288. .detailtextV{
  289. color: dimgray;
  290. font-size: 26rpx;
  291. width: 90%;
  292. }
  293. .skuViewCt{
  294. display: flex;
  295. flex-direction: column;
  296. justify-content:center;
  297. width: 100%;
  298. margin-top: 10rpx;
  299. }
  300. .contensbgg{
  301. display: flex;
  302. flex-wrap: wrap;
  303. justify-content:flex-start;
  304. align-items:center;
  305. }
  306. .guigeleixing{
  307. font-size: 26rpx;
  308. line-height: 40rpx;
  309. height: 40rpx;
  310. color: black;
  311. font-weight: bold;
  312. }
  313. .youhuixinxi{
  314. margin: 8rpx;
  315. padding: 4rpx;
  316. font-size: 26rpx;
  317. line-height: 54rpx;
  318. height: 54rpx;
  319. border: 2rpx solid lightgray;
  320. border-radius: 8rpx;
  321. }
  322. .xz{
  323. color: lightcoral;
  324. border: 2rpx solid lightcoral;
  325. border-radius: 8rpx;
  326. }
  327. .xiaoliang{
  328. margin-left: auto;
  329. margin-right: 30rpx;
  330. }
  331. .xsxqt{
  332. margin-top: 16rpx;
  333. padding-left: 30rpx;
  334. font-size: 30rpx;
  335. line-height: 80rpx;
  336. height: 80rpx;
  337. font-weight: bold;
  338. background-color:whitesmoke;
  339. }
  340. .shangpinwenmiao{
  341. width:92%;
  342. margin-left: 4%;
  343. font-size: 30rpx;
  344. }
  345. .bottomfloatV{
  346. position: fixed;
  347. flex-direction: row;
  348. align-items: center;
  349. left: 0;
  350. right: 0;
  351. bottom: 0;
  352. z-index: 999;
  353. background-color: whitesmoke;
  354. height: 140rpx;
  355. }
  356. .gouwuche{
  357. width: 120rpx;
  358. height: 120rpx;
  359. }
  360. .qjs{
  361. border-radius: 8rpx;
  362. padding: 6rpx;
  363. margin-left: auto;
  364. margin-right: 30rpx;
  365. font-size: 32rpx;
  366. height: 80rpx;
  367. line-height: 80rpx;
  368. }
  369. </style>