product.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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">包装:{{product.unit}}</text>
  19. </view>
  20. <view class="product-info-price">
  21. <text class="rmb">¥</text>
  22. <text class="price">{{product.price}}</text>
  23. <text class="unit" v-if="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. <view class="page-article-text">
  79. {{origin.summary}}
  80. </view>
  81. <image v-for="(item,index) in albumPics" :key="index" :src="$getimg+item|miniImg(75)+'/thumbnail/750x'" class="full-img" mode="widthFix"></image>
  82. </view>
  83. </view>
  84. <!-- 产品介绍 end -->
  85. <view class="bottom-flex-btn-wrap">
  86. <view class="bottom-flex-btn-content">
  87. <button type="default" :disabled="isPred==0?false:true" class="bottom-flex-btn" @click="focuse(params.productid)">有意向</button>
  88. <button type="default" class="bottom-flex-btn primary" @click="callnumber(phoneNumber)">打电话</button>
  89. </view>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. export default {
  95. data() {
  96. return {
  97. params:{
  98. token:'',
  99. tokenhead:'',
  100. productid:'',
  101. },
  102. phoneNumber:'',
  103. swiper: {
  104. indicatorDots: false,
  105. autoplay: true,
  106. interval: 9000,
  107. duration: 500
  108. },
  109. productresult:[],
  110. brand:[],
  111. companyinfo:[],
  112. origin:[],
  113. product:[],
  114. createTime:'',
  115. isPred:0,
  116. albumPics:null,
  117. firstimg:'',
  118. files:[],
  119. thispage:'',
  120. }
  121. },
  122. onShow() {
  123. let serf = this;
  124. //检查登录,获取token
  125. // let loginRes = this.checkLogin('/pages/index/index', '2');
  126. // if(!loginRes){return false;}
  127. // serf.params.token=loginRes[0];
  128. },
  129. onLoad(option) {
  130. let self = this;
  131. uni.getStorage({
  132. key:'token',
  133. success: function (res) {
  134. self.params.token = res.data;
  135. // console.log(res.data);
  136. }
  137. });
  138. uni.getStorage({
  139. key:'tokenhead',
  140. success: function (res) {
  141. self.params.tokenhead = res.data;
  142. // console.log(res.data);
  143. }
  144. });
  145. console.log('option',option);
  146. this.params.productid = option.id;
  147. this.thispage = `/#/pages/product/product?id=${this.params.productid}`;
  148. //获取产品
  149. //,{params:this.params}
  150. this.$api.http.get(this.config.apiBaseurl+'/product/detail/'+this.params.productid).then(res => {
  151. console.log('res',JSON.parse(JSON.stringify(res)));
  152. this.isPred = res.data.data.isPred;
  153. // console.log('this.isPred',this.isPred)
  154. this.productresult = res.data.data || '';
  155. this.brand = res.data.data.brand || '';
  156. this.companyinfo = res.data.data.companyInfo || '';
  157. this.origin = res.data.data.origin || '';
  158. this.product = res.data.data.product || '';
  159. this.albumPics = this.product.albumPics||'';
  160. this.albumPics = this.albumPics.split(',');
  161. this.files = res.data.data.companyInfo.files||'';
  162. this.firstimg = this.files[0].fileUrl||'';
  163. // console.log('this.albumPics',this.albumPics,'type',typeof this.albumPics,'this.firstimg',this.firstimg);
  164. this.phoneNumber = this.companyinfo.compConNum;//动态电话
  165. // this.phoneNumber = '13885026400';
  166. // console.log('this.brand',JSON.parse(JSON.stringify(this.brand)));
  167. // console.log('this.companyinfo',JSON.parse(JSON.stringify(this.companyinfo)));
  168. // console.log('this.origin',JSON.parse(JSON.stringify(this.origin)));
  169. // console.log('this.product',JSON.parse(JSON.stringify(this.product)));
  170. this.createTime = this.product.createTime.substring(0, 10);
  171. }).catch(err => {
  172. console.log(err)
  173. });
  174. },
  175. methods: {
  176. //有意向
  177. focuse(productid){
  178. console.log('this.thispage',this.thispage);
  179. let thetoken = this.params.tokenhead + this.params.token;
  180. this.$api.http.put(this.config.apiBaseurl+'/pre/add',{productId:productid},{header: {Authorization:thetoken}}).then(res => {
  181. console.log(res);
  182. uni.showToast({
  183. icon:'success',
  184. mask:true,
  185. title:`已添加到有意向`,
  186. duration: 2000
  187. });
  188. }).catch(err => {
  189. if(err.data.message =='暂未登录或token已经过期'){
  190. let loginurl = `${this.config.apiBaseurl}/wechat/h5/authorize?returnUrl=${this.thispage}`
  191. console.log('loginurl',loginurl);
  192. window.location.replace(loginurl);
  193. return
  194. }
  195. uni.showToast({
  196. icon:'none',
  197. mask:true,
  198. // title:err.data.message,
  199. title:'已经添加过',
  200. duration: 2000
  201. });
  202. console.log(err.data.message);
  203. });
  204. },
  205. //打电话
  206. callnumber(number){
  207. if(!number){
  208. uni.showToast({
  209. icon:'none',
  210. mask:true,
  211. title:`手机号码为空`,
  212. duration: 2000
  213. });
  214. return;
  215. };
  216. uni.makePhoneCall({
  217. phoneNumber: number
  218. });
  219. },
  220. // 跳转到供应商
  221. gocompany(id){
  222. uni.navigateTo({
  223. url:`/pages/supplier/supplierdetail/supplierdetail?id=${id}`
  224. })
  225. }
  226. }
  227. }
  228. </script>
  229. <style scoped>
  230. @import url("./product.css");
  231. </style>