detail.vue 11 KB

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