shangpinxiangqing.vue 8.7 KB

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