product.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="pages">
  3. <view class="appAdv nomal-bottom">
  4. <swiper class="swiper" :indicator-dots="swiper.indicatorDots" :autoplay="swiper.autoplay" :interval="swiper.interval" :duration="swiper.duration">
  5. <!-- <swiper-item v-for="(item,index) in albumPics" :key="index"> -->
  6. <swiper-item>
  7. <view class="adv-item"><image :src="$getimg+product.pic|miniImg(75)+'/thumbnail/750x'" class="pic" mode="aspectFit"></image></view>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <!-- 轮播结束 -->
  12. <view class="product-info-wrap">
  13. <view class="product-info-til">{{product.name}}</view>
  14. <view class="product-info-brand">{{product.brandName}}<!-- <text class="postage">包邮</text> --></view>
  15. <view class="product-info-item">
  16. <text class="item">保质期:{{product.qualityGuaranteePeriod||"参考包装"}}</text>
  17. <text class="item">生产日期:{{createTime}}</text>
  18. <text class="item" v-if="product.unit">包装:{{product.unit}}</text>
  19. </view>
  20. <view class="product-info-price">
  21. <text class="rmb" v-if="product.price">¥</text>
  22. <text class="price" :class="!product.price?'noprice':''">{{product.price||"暂无价格"}}</text>
  23. <text class="unit" v-if="product.price&&product.unit">/{{product.unit}}</text>
  24. </view>
  25. </view>
  26. <!-- 产品基本信息结束 -->
  27. <view class="write-radius supplier wrap">
  28. <view class="block-til">
  29. <view class="block-til-left">供应商</view>
  30. <view class="block-til-right" v-if="companyinfo.isCert==1">
  31. <view class="safe-icon">
  32. <image class="safe-icon-img" src="/static/img/icon-safe.png" mode=""></image>
  33. </view>
  34. 商家已缴纳诚信保证金
  35. </view>
  36. </view>
  37. <view class="placeoforigin-info" @click="gocompany(companyinfo.id)">
  38. <view class="placeoforigin-info-img-wrap" >
  39. <image class="placeoforigin-info-img" :src="firstimg||'/static/img/inbuild.png'|miniImg(75)+'/thumbnail/240x'" mode="aspectFit"></image>
  40. </view>
  41. <view class="placeoforigin-info-text">
  42. <view class="placeoforigin-info-text-til">{{companyinfo.compName}}</view>
  43. <view class="placeoforigin-info-text-con">
  44. <view class="placeoforigin-info-text-level">等级:{{companyinfo.compLevel}}级</view>
  45. <view class="placeoforigin-info-text-product">经营产品:{{companyinfo.compManageProduct}}</view>
  46. <view class="placeoforigin-info-text-addr">地址:{{ companyinfo.provinceId + companyinfo.cityId||''}}</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 供应商 end -->
  52. <view class="write-radius placeoforigin wrap">
  53. <view class="block-til">
  54. <view class="block-til-left">生产地</view>
  55. </view>
  56. <view class="placeoforigin-addr">{{product.placeOfProduction}}</view>
  57. </view>
  58. <!-- 生产地 end -->
  59. <view class="write-radius introduce wrap">
  60. <view class="block-til">
  61. <view class="block-til-left">产品介绍</view>
  62. </view>
  63. <!-- <view class="introduce-table">
  64. <view class="introduce-table-til">规格</view>
  65. <view class="introduce-table-con">
  66. <view class="introduce-table-row">
  67. <view class="introduce-table-col">5斤装</view>
  68. <view class="introduce-table-col">30.00元/件</view>
  69. </view>
  70. <view class="introduce-table-row">
  71. <view class="introduce-table-col">10斤装</view>
  72. <view class="introduce-table-col">50.00元/件</view>
  73. </view>
  74. </view>
  75. </view> -->
  76. <!-- introduce-table end -->
  77. <view class="page-article">
  78. <rich-text :nodes="product.description"></rich-text>
  79. <!-- <view class="page-article-text">
  80. {{product.description}}
  81. </view> -->
  82. <image v-for="(item,index) in albumPics" :key="index" :src="$getimg+item|miniImg(75)+'/thumbnail/750x'" class="full-img" mode="widthFix"></image>
  83. </view>
  84. </view>
  85. <!-- 产品介绍 end -->
  86. <view class="bottom-flex-btn-wrap">
  87. <view class="bottom-flex-btn-content">
  88. <button type="default" :disabled="isPred==0?false:true" class="bottom-flex-btn" @click="focuse(params.productid)">有意向</button>
  89. <button type="default" class="bottom-flex-btn" @click="buy(params.productid)">购买</button>
  90. <button type="default" class="bottom-flex-btn primary" @click="callnumber(phoneNumber)">打电话</button>
  91. </view>
  92. </view>
  93. <uni-popup ref="popup" type="dialog">
  94. <uni-popup-dialog type="info" content="还未绑定手机号码,是否去绑定?" :duration="2000" :before-close="true" @close="closepopup" @confirm="confirmpopup"></uni-popup-dialog>
  95. </uni-popup>
  96. <quick-buy class="quickbuy" :pData="this.productresult" ref="quickBuy" @closeModal="closeModal" v-if="modal.visibleModal"></quick-buy>
  97. </view>
  98. </template>
  99. <script>
  100. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  101. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  102. import quickBuy from './modal/quickBuy';
  103. export default {
  104. components: {
  105. uniPopup,
  106. uniPopupDialog,
  107. quickBuy,
  108. },
  109. data() {
  110. return {
  111. userInfo:null,
  112. params:{
  113. token:'',
  114. tokenhead:'',
  115. productid:'',
  116. },
  117. phoneNumber:'',
  118. swiper: {
  119. indicatorDots: false,
  120. autoplay: true,
  121. interval: 9000,
  122. duration: 500
  123. },
  124. productresult:[],
  125. brand:[],
  126. companyinfo:[],
  127. origin:[],
  128. product:[],
  129. createTime:'',
  130. isPred:0,
  131. albumPics:null,
  132. firstimg:'',
  133. files:[],
  134. thispage:'',
  135. modal: {
  136. visibleModal: false
  137. },
  138. }
  139. },
  140. onShow() {
  141. let serf = this;
  142. //检查登录,获取token
  143. // let loginRes = this.checkLogin('/pages/index/index', '2');
  144. // if(!loginRes){return false;}
  145. // serf.params.token=loginRes[0];
  146. },
  147. onLoad(option) {
  148. let self = this;
  149. uni.getStorage({
  150. key:'token',
  151. success: function (res) {
  152. self.params.token = res.data;
  153. // console.log(res.data);
  154. }
  155. });
  156. uni.getStorage({
  157. key:'tokenhead',
  158. success: function (res) {
  159. self.params.tokenhead = res.data;
  160. // console.log(res.data);
  161. }
  162. });
  163. uni.getStorage({
  164. key:'userInfo',
  165. success: function (res) {
  166. self.userInfo = res.data.user;
  167. // console.log('userInfo',self.userInfo);
  168. }
  169. });
  170. // console.log('option',option);
  171. this.params.productid = option.id;
  172. this.thispage = `/#/pages/product/product?id=${this.params.productid}`;
  173. //获取产品
  174. //,{params:this.params}
  175. this.$api.http.get(this.config.apiBaseurl+'/product/detail/'+this.params.productid).then(res => {
  176. console.log('res',JSON.parse(JSON.stringify(res)));
  177. this.isPred = res.data.data.isPred;
  178. // console.log('this.isPred',this.isPred)
  179. this.productresult = res.data.data || '';
  180. this.brand = res.data.data.brand || '';
  181. this.companyinfo = res.data.data.companyInfo || '';
  182. this.origin = res.data.data.origin || '';
  183. this.product = res.data.data.product || '';
  184. this.albumPics = this.product.albumPics||'';
  185. this.albumPics = this.albumPics.split(',');
  186. this.files = res.data.data.companyInfo.files||'';
  187. this.firstimg = this.files[0].fileUrl||'';
  188. // console.log('this.albumPics',this.albumPics,'type',typeof this.albumPics,'this.firstimg',this.firstimg);
  189. this.phoneNumber = this.companyinfo.compConNum;//动态电话
  190. // this.phoneNumber = '13885026400';
  191. // console.log('this.brand',JSON.parse(JSON.stringify(this.brand)));
  192. // console.log('this.companyinfo',JSON.parse(JSON.stringify(this.companyinfo)));
  193. // console.log('this.origin',JSON.parse(JSON.stringify(this.origin)));
  194. // console.log('this.product',JSON.parse(JSON.stringify(this.product)));
  195. this.createTime = this.product.createTime.substring(0, 10);
  196. }).catch(err => {
  197. console.log(err)
  198. });
  199. },
  200. methods: {
  201. //有意向
  202. focuse(productid){
  203. console.log('this.thispage',this.thispage);
  204. //没有手机号,提醒去绑定
  205. // if(!this.userInfo.phone){
  206. // this.$refs.popup.open();
  207. // return false;
  208. // };
  209. let thetoken = this.params.tokenhead + this.params.token;
  210. this.$api.http.put(this.config.apiBaseurl+'/pre/add',{productId:productid},{header: {Authorization:thetoken}}).then(res => {
  211. if(res.data.code!=200){
  212. uni.showToast({
  213. icon:"none",
  214. title:res.data.message,
  215. duration: 2000
  216. });
  217. return false;
  218. };
  219. console.log(res);
  220. uni.showToast({
  221. icon:'success',
  222. mask:true,
  223. title:`已添加到有意向`,
  224. duration: 2000
  225. });
  226. }).catch(err => {
  227. uni.showToast({
  228. icon:'none',
  229. mask:true,
  230. // title:err.data.message,
  231. title:err.data.message,
  232. duration: 2000
  233. });
  234. console.log(err.data.message);
  235. });
  236. },
  237. //打电话
  238. callnumber(number){
  239. if(!number){
  240. uni.showToast({
  241. icon:'none',
  242. mask:true,
  243. title:`手机号码为空`,
  244. duration: 2000
  245. });
  246. return;
  247. };
  248. uni.makePhoneCall({
  249. phoneNumber: number
  250. });
  251. },
  252. // 跳转到供应商
  253. gocompany(id){
  254. uni.navigateTo({
  255. url:`/pages/supplier/supplierdetail/supplierdetail?id=${id}`
  256. })
  257. },
  258. closeModal(){
  259. console.log('111111');
  260. this.modal.visibleModal = false;
  261. },
  262. closepopup(done){
  263. done()
  264. },
  265. confirmpopup(done,value){
  266. uni.navigateTo({
  267. url:'/pages/usercenter/bindphone/bindphone'
  268. });
  269. done()
  270. },
  271. buy(item){
  272. console.log('item',item);
  273. if(!this.product.price){
  274. uni.showToast({
  275. icon:'none',
  276. mask:true,
  277. title:`暂时无法购买`,
  278. duration: 2000
  279. });
  280. return false;
  281. };
  282. this.modal.visibleModal = true;
  283. this.$nextTick(res => {
  284. this.$refs.quickBuy.openPop();
  285. });
  286. }
  287. }
  288. }
  289. </script>
  290. <style scoped>
  291. @import url("./product.css");
  292. </style>