detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <view v-if="allShow">
  3. <!--pages/detail/detail.wxml-->
  4. <view class="banner">
  5. <swiper class="swiper" @change="swiperChange" :current="current" autoplay="true" circular="true"
  6. duration="1000">
  7. <block v-for="(item, index) in product.images" :key="index">
  8. <swiper-item autoplay="true">
  9. <image :src="item" mode="aspectFit"></image>
  10. </swiper-item>
  11. </block>
  12. </swiper>
  13. <view class="dots dflex">
  14. <block v-for="(item, index) in product.images" :key="index">
  15. <view :class="'dot ' + (index == swiperCurrent ? ' active' : '')" :data-current="index"
  16. @tap="dotEvent"></view>
  17. </block>
  18. </view>
  19. </view>
  20. <view class="info bgfff">
  21. <view class="infos dflex">
  22. <view class="title">{{product.title?product.title:''}}</view>
  23. <button class="share" open-type="share">
  24. <image src="/static/pages/images/fxico.png"></image>分享
  25. </button>
  26. </view>
  27. <view class="protext">
  28. {{product.brandName ? product.brandName : ''}} {{product.brief ? product.brief : ''}}
  29. </view>
  30. </view>
  31. <view class="detinfo mt20 bgfff">
  32. <view class="item pro-sel dflex" v-if="skuList.length>0">
  33. <view class="tag" v-for="it,idx in skuList" :key="idx">{{JSON.parse(it.properties)[0].value}}</view>
  34. </view>
  35. <view class="item pro-sel dflex" v-if="product.label">
  36. <label>标签</label>
  37. <view class="flex">{{product.label}}</view>
  38. </view>
  39. </view>
  40. <!-- 商品详情等页面 -->
  41. <product-footer ref="list" id="list" :detail="nodes" :imgs="imgs" :proId="product.id" :form="form"
  42. @scoreTab="scoreTab" @showTab="showTab" v-if="product.id" @freshen="freshenFun" @getForm="getForm">
  43. </product-footer>
  44. <v-share :hide-toast="hideShare" :product="product" :code-url="codeUrl" @onFather="click"></v-share>
  45. <view class="bottom-text" style="margin-top: 30rpx;" v-if="recommendCard.realName">
  46. <view>{{config.CONFIG_COMPANY_NAME?config.CONFIG_COMPANY_NAME:'中国人寿保险股份有限公司'}}
  47. {{recommendCard.realName}}向您推荐</view>
  48. <view>电话: {{recommendCard.phone}}</view>
  49. <view v-if="recommendCard.professionalCertificateNo">执业证书: {{recommendCard.professionalCertificateNo}}</view>
  50. </view>
  51. <view class="bottom-text" style="margin:0 30rpx 30rpx;border-top: 2rpx solid #e5e5e5;">
  52. <view>{{config.CONFIG_COMPANY_NAME?config.CONFIG_COMPANY_NAME:'中国人寿保险股份有限公司'}} 版权所有</view>
  53. <view v-if="config.CONFIG_COMPANY_EMAIL">{{config.CONFIG_COMPANY_EMAIL}}</view>
  54. <view v-if="config.CONFIG_COMPANY_PHONE">客户服务专线:{{config.CONFIG_COMPANY_PHONE}}</view>
  55. <view v-if="config.CONFIG_COMPANY_FILING_NUMBER">{{config.CONFIG_COMPANY_FILING_NUMBER}}</view>
  56. </view>
  57. <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 140) + 'rpx'"></view>
  58. <view class="bot fixed bgfff dflex">
  59. <view class="fflex ddflex">
  60. <view class="botbtn fflex" style="border-right: 1px solid #fff;" v-if="recommendCard.wechat||recommendCard.wechatCode||recommendCard.wechatCompanyCode"
  61. @click="showCodePop()">
  62. 加微咨询
  63. </view>
  64. <view class="botbtn fflex" @click="callPhone(recommendCard.phone)" v-if="recommendCard.phone">
  65. 电话咨询
  66. </view>
  67. </view>
  68. <view class="botbtn fflex" style="border-left: 1px solid #fff;background-color: red;" @click="toBuy()" v-if="product.linkUrl">
  69. 购买
  70. </view>
  71. </view>
  72. <view class="xiajia" v-if="product.state !=1">您来晚了,产品已经下架</view>
  73. <view class="contact_index" @tap="goTop">
  74. <image src="/static/pages/images/backtop.png"></image>顶部
  75. </view>
  76. <view :class="'chat-fixed '+(chatShow?'chat-fixed-long':'')"
  77. v-if="recommendCard&&recommendCard.id&&userInfo.id!=recommendCard.userId">
  78. <view class="chat-box ddflex" @click="jumpSingleChatRoom()">
  79. <image :src="recommendCard.avatar?recommendCard.avatar:'../../static/pages/images/userimg.png'"></image>
  80. <view v-if="chatShowText" class="fflex tover"
  81. style="font-size: 24rpx;color: #333333;margin-left: 20rpx;">您好,我是{{recommendCard.realName}},欢迎访问我的微页
  82. </view>
  83. <view :class="'chat-lyl '+(!chatShowText?'chat-lyl2':'')">聊一聊</view>
  84. </view>
  85. </view>
  86. <view class="ceng2" v-if="isShowCodePop" @click="isShowCodePop = false" @touchmove.stop.prevent="moveHandle">
  87. </view>
  88. <view :class="'code-pop ' +(about.greyTheme==1?'grayTheme':'')" v-if="isShowCodePop">
  89. <view v-if="recommendCard.wechatCode||recommendCard.wechatCompanyCode" class="ddflex" style="justify-content: center;">
  90. <view class="code-content" v-if="recommendCard.wechatCode">
  91. <image :src="recommendCard.wechatCode?recommendCard.wechatCode:'/static/images/wxCode.jpg'" :style="recommendCard.wechatCompanyCode?'width: 200rpx;height: 200rpx;':''"
  92. show-menu-by-longpress="true"></image>
  93. <view style="text-align: center;font-size: 24rpx;color: #999;margin-bottom: 50rpx;">长按识别微信二维码</view>
  94. </view>
  95. <view class="code-content" v-if="recommendCard.wechatCompanyCode" :style="recommendCard.wechatCode?'margin-left:30rpx':''">
  96. <image :src="recommendCard.wechatCompanyCode?recommendCard.wechatCompanyCode:'/static/images/wxCode.jpg'" :style="recommendCard.wechatCode?'width: 200rpx;height: 200rpx;':''"
  97. show-menu-by-longpress="true"></image>
  98. <view style="text-align: center;font-size: 24rpx;color: #999;margin-bottom: 50rpx;">长按识别企微二维码</view>
  99. </view>
  100. </view>
  101. <view class="code-text" v-else>
  102. <view>微信号</view>
  103. <view>{{recommendCard.wechat}}</view>
  104. </view>
  105. <view class="code-btn" @click="copy(recommendCard.wechat)" v-if="recommendCard.wechat">
  106. 复制微信号
  107. </view>
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. const app = getApp();
  113. const req = require("../../utils/request.js");
  114. const utils = require("../../utils/util.js");
  115. var QQMapWX = require("../../utils/qqmap.js");
  116. const route = require("../../utils/route");
  117. const api = require("../../utils/api.js");
  118. import productFooter from "../components/product_footer/index";
  119. export default {
  120. data() {
  121. return {
  122. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  123. swiperCurrent: 0,
  124. bannerUrls: [],
  125. isShow: false,
  126. pro: {},
  127. isCart: false,
  128. timer: [],
  129. hideShare: true,
  130. codeUrl: '',
  131. form: {
  132. page: 1,
  133. limit: 10
  134. },
  135. freshen: true,
  136. //是否更新页面
  137. isActive: false,
  138. current: "",
  139. query: "",
  140. userInfo: "",
  141. shopId: "",
  142. params: "",
  143. product: "",
  144. nodes: "",
  145. imgs: [],
  146. tabe: "",
  147. load: false,
  148. address: {},
  149. index: "",
  150. popup: "",
  151. tabIndex: "",
  152. switch: true,
  153. about: {},
  154. allShow: false,
  155. isVideoScene: false, //立即购买是否需要登录
  156. isShowUpdate: false, //是否显示更新信息弹窗
  157. isUpdateInfo: false, //更新用户信息
  158. isUpdateMobile: false, //绑定手机号
  159. recommendCard: {},
  160. chatShow: true,
  161. chatShowText: true,
  162. isShowCodePop: false,
  163. config: {},
  164. skuList:[]
  165. };
  166. },
  167. components: {
  168. productFooter,
  169. },
  170. props: {},
  171. onLoad: async function(options) {
  172. let that = this;
  173. this.query = options;
  174. if(options.shareId) req.setStorage('shareId',options.shareId)
  175. if (options.scene) {
  176. this.scene = options.scene;
  177. }
  178. this.getConfig()
  179. await req.silenceLogin();
  180. },
  181. onShow: async function() {
  182. await req.silenceLogin();
  183. this.userInfo = req.getStorage('userInfo')
  184. if (this.scene) {
  185. this.query.id = this.scene
  186. }
  187. this.loadProudct()
  188. // await this.browsRecound(this.query.id);
  189. QQMapWX.initMap();
  190. req.getLocation(res => {
  191. const to = {
  192. latitude: res.latitude,
  193. longitude: res.longitude
  194. };
  195. QQMapWX.reverseGeocoder(to, resp => {});
  196. this.getRecommendCard(to)
  197. });
  198. },
  199. onShareAppMessage: function(options) {
  200. let merchantId = '';
  201. let path = 'id=' + this.query.id
  202. let userInfo = req.getStorage('userInfo');
  203. if (!userInfo.id) {} else {
  204. path += '&userId=' + userInfo.id;
  205. }
  206. if(userInfo.userType==1){
  207. path += '&shareId=' + req.getStorage('userInfo').saleNo
  208. }
  209. let url = '/product/detail/detail?' + path;
  210. return {
  211. title: this.product.title,
  212. imageUrl: this.product.pic,
  213. path: url
  214. };
  215. },
  216. // onShareTimeline() {
  217. // let merchantId = '';
  218. // let path = 'id=' + this.query.id
  219. // let userInfo = req.getStorage('userInfo');
  220. // if (!userInfo.id) {} else {
  221. // path += '&userId=' + userInfo.id;
  222. // }
  223. // let url = '/product/detail/detail?' + path;
  224. // return {
  225. // title: this.product.title,
  226. // query: path,
  227. // imageUrl: this.product.images[0]
  228. // };
  229. // },
  230. onReachBottom() {},
  231. methods: {
  232. getConfig() {
  233. req.getRequest('/api/other/config', {}, data => {
  234. req.setStorage('configRes', JSON.stringify(data));
  235. this.config = data;
  236. })
  237. },
  238. click(e) {
  239. // console.log(e,"7899")
  240. this.hideShare = e
  241. },
  242. /**
  243. * 轮播切换
  244. */
  245. swiperChange({
  246. detail
  247. }) {
  248. if (this.current == 0 && this.swiperCurrent > 1) {
  249. //卡死时,重置current为正确索引
  250. this.setData({
  251. current: this.swiperCurrent
  252. });
  253. } else {
  254. //正常轮转时,记录正确页码索引
  255. this.setData({
  256. swiperCurrent: detail.current
  257. });
  258. }
  259. },
  260. dotEvent(e) {
  261. this.setData({
  262. current: e.currentTarget.dataset.current
  263. });
  264. },
  265. // 获取推荐销售
  266. getRecommendCard(loction) {
  267. let params = loction
  268. if (req.getStorage("shareId")) {
  269. params.shareSaleNo = req.getStorage("shareId")
  270. }
  271. req.getRequest('/api/visiting/card/recommendCardInfo', params, res => {
  272. this.recommendCard = res
  273. console.log('获取推荐销售》》》》》', res);
  274. setTimeout(() => {
  275. this.chatShow = false
  276. setTimeout(() => {
  277. this.chatShowText = false
  278. }, 450)
  279. }, 2000)
  280. })
  281. },
  282. loadProudct() {
  283. let that = this;
  284. that.setData({
  285. bannerUrls: [],
  286. product: '',
  287. nodes: ''
  288. });
  289. let form = {
  290. id: this.query.id
  291. };
  292. let isShowLoading = false;
  293. this.allShow = false
  294. if (!isShowLoading) {
  295. req.loadIng('加载中');
  296. isShowLoading = true;
  297. }
  298. req.getRequest('/api/v1/product/detail', form, data => {
  299. //富文本图片放大
  300. var nodes = data.detail;
  301. let tabe = [];
  302. that.setData({
  303. bannerUrls: data.images,
  304. product: data,
  305. nodes: nodes,
  306. tabe: tabe,
  307. load: true,
  308. allShow: true
  309. });
  310. this.loadProductSku()
  311. if (isShowLoading) {
  312. uni.hideLoading();
  313. isShowLoading = false;
  314. }
  315. });
  316. },
  317. loadProductSku() {
  318. let _ts = this;
  319. let from = {
  320. id : this.product.id
  321. }
  322. return new Promise((resolve, reject) => {
  323. req.getRequest(
  324. '/api/v1/product/sku',
  325. from,
  326. res => {
  327. this.skuList = res
  328. resolve();
  329. },
  330. true
  331. );
  332. });
  333. },
  334. goTop(e) {
  335. // 一键回到顶部
  336. if (uni.pageScrollTo) {
  337. uni.pageScrollTo({
  338. scrollTop: 0
  339. });
  340. } else {
  341. uni.showModal({
  342. title: '提示',
  343. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  344. });
  345. }
  346. },
  347. jumpUrl(url) {
  348. uni.navigateTo({
  349. url: url
  350. })
  351. },
  352. closeUpdate() {
  353. this.isShowUpdate = false
  354. this.isUpdateInfo = false;
  355. this.isUpdateMobile = false;
  356. },
  357. showCodePop() {
  358. this.isShowCodePop = true
  359. req.saveBehaviorNew(this.recommendCard.id, 1, 18)
  360. },
  361. // 拨打电话
  362. callPhone(val) {
  363. if (!val) return false
  364. uni.makePhoneCall({
  365. phoneNumber: val
  366. });
  367. },
  368. copy(val) {
  369. this.isShowCodePop = false
  370. uni.setClipboardData({
  371. data: val,
  372. complete() {
  373. req.msg('复制成功')
  374. }
  375. })
  376. },
  377. jumpSingleChatRoom() {
  378. if (this.recommendCard) {
  379. req.jumpSingleChatRoom(this.recommendCard.userId, this.recommendCard.avatar, this.recommendCard
  380. .realName);
  381. req.saveBehaviorNew(this.recommendCard.id, 1, 14)
  382. }
  383. },
  384. toBuy(){
  385. if(!this.product.linkUrl) return false
  386. app.globalData.openPage('pages/web/web?url='+encodeURIComponent(this.product.linkUrl));
  387. }
  388. }
  389. };
  390. </script>
  391. <style>
  392. @import "./detail.css";
  393. </style>