product.vue 8.0 KB

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