index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <view v-if="isShowView">
  3. <view class="con-top">
  4. <block v-for="(item, index) in params.params.jsonContent" :key="index">
  5. <view class="ban" v-if="item.key == 'banner'">
  6. <swiper class="swiper" @change="swiperChange" autoplay="true" interval="5000" duration="300">
  7. <block v-for="(it, idx) in item.value.imageList" :key="idx">
  8. <swiper-item><image lazy-load="true" :src="it.src" mode="aspectFill" @click="clickBanner(item)"></image></swiper-item>
  9. </block>
  10. </swiper>
  11. <view class="dots ddflex">
  12. <block v-for="(it, idx) in item.value.imageList" :key="idx"><view :class="['dot', idx == swiperCurrent ? 'active' : '']"></view></block>
  13. </view>
  14. </view>
  15. <view class="richText" v-if="item.key == 'text'"><rich-text :nodes="item.value.content"></rich-text></view>
  16. <!-- <block v-if="item.key == 'product'">
  17. <view class="product" v-if="item.value.layoutNum == 1">
  18. <view class="li ddflex" v-for="(it, idx) in item.value.productList" :key="idx" @click="jumpUrl('/product/detail/detail?id=' + it.id)">
  19. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  20. <view class="pro-info fflex">
  21. <view class="pro-name tovers">{{ it.title }}</view>
  22. <view class="pro-bri tover" v-if="it.brief">{{ it.brief }}</view>
  23. <view class="pro-opt ddflex">
  24. <view class="money">
  25. ¥{{ it.minSalePrice }}
  26. <text>/起</text>
  27. </view>
  28. <view class="pro-btn">立即购买</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </block> -->
  34. <view class="images" v-if="item.key == 'images'"><image :src="item.value.src" mode="widthFix"></image></view>
  35. <block v-if="item.key == 'customerService'"></block>
  36. <button open-type="contact" class="contact ddflex" v-if="item.value.type == '0'">
  37. <image src="../static/kfico.png"></image>
  38. 客服
  39. </button>
  40. <view class="contact ddflex" @click="customerServiceChat(item.value)" v-if="item.value.type == '1'">
  41. <image src="../static/kfico.png"></image>
  42. 客服
  43. </view>
  44. <view class="contact ddflex" @click="jumpHref(item.value)" v-if="item.value.type == '2'">
  45. <image src="../static/kfico.png"></image>
  46. 客服
  47. </view>
  48. </block>
  49. <!-- #ifdef MP-WEIXIN -->
  50. <!-- <image src="../static/images/kdx_img6.jpg" mode="widthFix"></image> -->
  51. <!-- #endif -->
  52. </view>
  53. <view class="item6">
  54. <view class="item6-top">
  55. <image :src="picUrlss+'lvluo/home_bg3.png'" class="bg3"></image>
  56. <view class="item6-top-c ddflex">
  57. <view>添加金牌顾问微信~</view>
  58. <text>领取超值优惠</text>
  59. </view>
  60. </view>
  61. <view class="item6-con">
  62. <view class="item6-con-t">
  63. <image :src="sysUserInfo.headUrl?sysUserInfo.headUrl:'../../static/pages/images/userimg.png'" class="kf-img"></image>
  64. <view class="name">{{sysUserInfo.realName?sysUserInfo.realName:sysUserInfo.username}}</view>
  65. <view class="mobile" @click="call(sysUserInfo.mobile)" v-if="sysUserInfo.mobile">{{sysUserInfo.mobile}}</view>
  66. <view class="tag">绿萝云-诊所私域专家</view>
  67. </view>
  68. <view class="qrcode" v-if="sysUserInfo.wechatQrcode">
  69. <image :src="sysUserInfo.wechatQrcode" show-menu-by-longpress="true"></image>
  70. <view>长按扫码添加微信</view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- #ifdef MP-WEIXIN -->
  75. <view class="price-list" v-if="skuList.length>0">
  76. <view class="li" v-for="(item, index) in skuList" :key="index" @click="checkSkuClick(index)">
  77. <block v-if="index == 0">
  78. <image src="../static/images/xianliang_bg.png" class="li-bg"></image>
  79. <image src="../static/images/xianliang.png" class="price-tag"></image>
  80. <view class="li-c ddflex" style="background: none;">
  81. <image :src="item.active ? '../static/images/kdx_gou_h.png' : '../static/images/kdx_gou.png'" class="gou"></image>
  82. <view class="price ddflex fflex">
  83. <text class="price-fh">¥</text>
  84. {{ item.salePrice }}
  85. <text class="price-dw">/{{ item.skuStr }}</text>
  86. </view>
  87. <view class="price-txt">
  88. 抢先价
  89. <text>2023-01-01恢复定价</text>
  90. </view>
  91. </view>
  92. </block>
  93. <view class="li-c ddflex" v-else>
  94. <image :src="item.active ? '../static/images/kdx_gou_h.png' : '../static/images/kdx_gou.png'" class="gou"></image>
  95. <view class="price ddflex fflex">
  96. <text class="price-fh">¥</text>
  97. {{ item.salePrice }}
  98. <text class="price-dw">/{{ item.skuStr }}</text>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- #endif -->
  104. <!-- <view class="supp">由智企云提供技术支持</view> -->
  105. <view class="bot">
  106. <!-- #ifndef MP-WEIXIN -->
  107. <!-- <view class="btn" @click="toWxShare()">推荐给朋友,赢免单机会</view> -->
  108. <!-- #endif -->
  109. <!-- #ifdef MP-WEIXIN -->
  110. <!-- <view class="btn" @click="directBuy()">支付 ¥{{ checkSku.salePrice }} 马上开通</view> -->
  111. <!-- #endif -->
  112. </view>
  113. </view>
  114. </template>
  115. <script>
  116. const req = require('../../utils/request.js');
  117. const api = require('../../utils/api.js');
  118. const util = require('../../utils/util.js');
  119. const app = getApp();
  120. export default {
  121. data() {
  122. return {
  123. picUrlss: req.public.picUrls,
  124. isShowView: '',
  125. options: {},
  126. params: '',
  127. swiperCurrent: 0,
  128. hideShare: true,
  129. codeUrl: '',
  130. userInfo: {},
  131. sys_userInfo: {},
  132. saveId: '',
  133. skuList: [],
  134. checkSku: '',
  135. productId: '',
  136. sysUserInfo: ''
  137. };
  138. },
  139. async onLoad(options) {
  140. this.options = options;
  141. this.userInfo = req.getStorage('userInfo');
  142. this.sys_userInfo = req.getStorage('sys_userInfo');
  143. if (options.userId) {
  144. req.setStorage('pidCode', options.userId);
  145. }
  146. if (options.saveBehaviorId) {
  147. this.saveId = options.saveBehaviorId;
  148. }
  149. // #ifdef MP-WEIXIN
  150. req.silenceLogin(options.userId, '');
  151. // #endif
  152. await this.getParams();
  153. await this.saveBehavior(4);
  154. if(options.sys_userId) await this.getSysDetail();
  155. },
  156. onShow() {},
  157. onUnload() {
  158. this.updateBehavior();
  159. },
  160. methods: {
  161. getSysDetail() {
  162. let that = this;
  163. let apiUrl = '/api/v3/sysUser/info';
  164. return new Promise((resolve,reject)=>{
  165. req.getRequest(apiUrl,{ id: that.options.sys_userId },async res => {
  166. that.sysUserInfo = res;
  167. resolve();
  168. },true);
  169. })
  170. },
  171. getParams() {
  172. let that = this;
  173. let params = {
  174. code: this.options.code
  175. };
  176. return new Promise((resolve, reject) => {
  177. req.getRequest('/api/v3/material/library/detail', params, data => {
  178. data.params.jsonContent.map(item => {
  179. if (item.key == 'applicationForm') {
  180. item.value.formItemList.map(it => {
  181. if (it.label.indexOf('姓名') > -1) {
  182. if (that.userInfo.nickName) {
  183. it.fieldValue = that.userInfo.nickName;
  184. }
  185. }
  186. if (it.dataType == 1) {
  187. if (that.userInfo.mobile) {
  188. it.fieldValue = that.userInfo.mobile;
  189. }
  190. }
  191. if (it.type == 5) {
  192. it.option = ['大健康', '快销品'];
  193. }
  194. });
  195. }
  196. return item;
  197. });
  198. that.params = data;
  199. uni.setNavigationBarTitle({
  200. title: data.title
  201. });
  202. console.log('data.title==', data.title);
  203. that.getProductSku();
  204. that.isShowView = true;
  205. resolve();
  206. });
  207. });
  208. },
  209. /**
  210. * 获取产品的sku
  211. */
  212. getProductSku() {
  213. var tha = this;
  214. tha.params.params.jsonContent.map(item => {
  215. if (item.key == 'product') {
  216. item.value.productList.map(it => {
  217. tha.getProductDetail(it.id);
  218. });
  219. }
  220. });
  221. },
  222. getProductDetail(productId) {
  223. this.productId = productId;
  224. let form = {
  225. id: productId
  226. };
  227. req.getRequest('/api/product/sku', form, data => {
  228. data.forEach(it => {
  229. if (it.properties == -1 || it.properties == 'DEFAULT_SKU') {
  230. } else {
  231. it.skuStr = JSON.parse(it.properties)
  232. .map(ij => ij.value.replace(' ', ''))
  233. .join(' ');
  234. it.active = false;
  235. }
  236. });
  237. data[0].active = true;
  238. this.skuList = data;
  239. this.checkSku = this.skuList[0];
  240. console.log('skuList====', this.skuList);
  241. });
  242. },
  243. checkSkuClick(idx) {
  244. this.skuList.map(it => {
  245. it.active = false;
  246. return it;
  247. });
  248. this.skuList[idx].active = true;
  249. this.checkSku = this.skuList[idx];
  250. },
  251. saveBehavior(behavior) {
  252. let params = {
  253. behavior: behavior,
  254. type: 7,
  255. bindId: this.params.libraryId
  256. };
  257. if (req.getStorage('pidCode')) {
  258. params.pid = req.getStorage('pidCode');
  259. }
  260. if (this.saveId) {
  261. params.parentId = this.saveId;
  262. }
  263. req.saveBehavior(params, data => {
  264. if (behavior != 6) {
  265. this.saveId = data;
  266. }
  267. });
  268. },
  269. updateBehavior() {
  270. let params = {
  271. id: this.saveId
  272. };
  273. req.getBehaviorUpdate(params, data => {});
  274. },
  275. swiperChange(e) {
  276. this.swiperCurrent = e.detail.current;
  277. },
  278. jumpUrl(url) {
  279. uni.navigateTo({
  280. url: url
  281. });
  282. },
  283. customerServiceChat(item) {
  284. wx.openCustomerServiceChat({
  285. extInfo: {
  286. url: item.target
  287. },
  288. corpId: item.id,
  289. success(res) {
  290. console.log('调用微信客服');
  291. }
  292. });
  293. },
  294. jumpHref(item) {
  295. window.location.href = item.target;
  296. },
  297. toWxShare() {
  298. req.getWXOriginalId(data => {
  299. if (data) {
  300. this.share(data);
  301. } else {
  302. req.msg('未获取到小程序原始ID');
  303. }
  304. }, req.public.appId);
  305. },
  306. share(originalId) {
  307. uni.share({
  308. provider: 'weixin',
  309. scene: 'WXSceneSession',
  310. type: 5,
  311. imageUrl: this.params.pic + '?x-oss-process=style/w375',
  312. title: this.params.title,
  313. summary: '来自' + (this.userInfo.realName ? this.userInfo.realName : this.userInfo.nickName) + '的邀请',
  314. miniProgram: {
  315. id: originalId,
  316. path: '/share/invite/index?userId=' + this.sys_userInfo.id + '&code=' + this.params.code,
  317. type: req.env[req.env.NODE_ENV].typeMiniProgram,
  318. webUrl: 'http://www.zhiqiyun.com'
  319. },
  320. success: ret => {
  321. console.log(JSON.stringify(ret));
  322. }
  323. });
  324. },
  325. getDataParams() {
  326. //加入购物车
  327. let _ts = this;
  328. const params = {
  329. skuId: this.checkSku.skuId,
  330. quantity: 1,
  331. productId: this.productId
  332. };
  333. return params;
  334. },
  335. directBuy() {
  336. let _ts = this;
  337. if (_ts.checkSku.stock == 0) return req.msg('库存不足');
  338. let params = _ts.getDataParams();
  339. let isShowLoading = false;
  340. if (!isShowLoading) {
  341. req.loadIng('加载中');
  342. isShowLoading = true;
  343. }
  344. req.postRequest('/api/purchase/direct/buy', params, res => {
  345. let redirect = '/product/subOrder/subOrder?ids=' + res;
  346. redirect += '&orderType=' + 1;
  347. if (isShowLoading) {
  348. uni.hideLoading();
  349. isShowLoading = false;
  350. }
  351. uni.navigateTo({
  352. url: redirect
  353. });
  354. });
  355. }
  356. }
  357. };
  358. </script>
  359. <style>
  360. @import './index.css';
  361. </style>