index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view v-if="isShowPage">
  3. <view :class="'top-fixed' + (skinNotColor ? ' not-color' : '')" :style="'height: '+ systems.barHeight + 'rpx;'">
  4. <view :class="'bgcolor' + (isTop == 1 ? ' opacity' : '')" :style="'height:' + systems.barHeight + 'rpx'"></view>
  5. <view class="top-fixed-c" :style="'height: '+ systems.navigationHeight + 'rpx;margin-top:' + systems.ktxStatusHeight + 'rpx;'">
  6. <view class="top-title tover" :style="'line-height: '+ systems.navigationHeight + 'rpx;'" v-if="isTop == 1">{{params.title}}</view>
  7. </view>
  8. </view>
  9. <block v-for="(item,index) in params.params.jsonContent" :key="index">
  10. <view class="ban" v-if="item.key == 'banner'">
  11. <swiper class="swiper" @change="swiperChange" autoplay="true" interval="5000" duration="300">
  12. <block v-for="(it, idx) in item.value.imageList" :key="idx">
  13. <swiper-item>
  14. <image lazy-load="true" :src="it.src" mode="aspectFill" @click="clickBanner(item)"></image>
  15. </swiper-item>
  16. </block>
  17. </swiper>
  18. <view class="dots ddflex">
  19. <block v-for="(it, idx) in item.value.imageList" :key="idx"><view :class="['dot', idx == swiperCurrent ? 'active' : '']"></view></block>
  20. </view>
  21. </view>
  22. <view class="form" v-if="item.key == 'applicationForm'">
  23. <view class="form-title" v-if="item.value.title.isShow">{{item.value.title.value}}</view>
  24. <view class="form-list">
  25. <view class="li" v-for="(it,idx) in item.value.formItemList" :key="idx">
  26. <view class="label">{{it.label}}</view>
  27. <block v-if="it.type == 1">
  28. <button open-type="getPhoneNumber" hover-class="none" @getphonenumber="getPhoneNumber" :class="'phone-ipt fflex' + (it.fieldValue?'':' placeholder')" v-if="it.dataType == 1">
  29. <block v-if="it.fieldValue">{{it.fieldValue}}</block>
  30. <block v-else>请填写{{it.label}}</block>
  31. </button>
  32. <input v-model="it.fieldValue" :placeholder="'请填写' + it.label" placeholder-class="placeholder" class="ipt fflex" v-else />
  33. </block>
  34. <textarea v-model="it.fieldValue" :placeholder="'请填写' + it.label" placeholder-class="placeholder" class="textarea fflex" v-else-if="it.type == 4"></textarea>
  35. <picker :range="it.option" class="pickers fflex" @change="changeOptions($event,idx)" v-else-if="it.type == 5">
  36. <view v-if="it.fieldValue">{{it.fieldValue}}</view>
  37. <view class="placeholder" v-else>请选择{{it.label}}</view>
  38. </picker>
  39. </view>
  40. </view>
  41. <view class="form-btn" @click="formSubmit(item.value)">{{item.value.buttonName}}</view>
  42. </view>
  43. <view class="richText" v-if="item.key == 'text'">
  44. <rich-text :nodes="item.value.content"></rich-text>
  45. </view>
  46. <block v-if="item.key == 'product'">
  47. <view class="product" v-if="item.value.layoutNum == 1">
  48. <view class="li ddflex" v-for="(it,idx) in item.value.productList" :key="idx" @click="jumpUrl('/product/detail/detail?id=' + it.id)">
  49. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  50. <view class="pro-info fflex">
  51. <view class="pro-name tovers">{{it.title}}</view>
  52. <view class="pro-bri tover" v-if="it.brief">{{it.brief}}</view>
  53. <view class="pro-opt ddflex">
  54. <view class="money">¥{{it.minSalePrice}}<text>/起</text></view>
  55. <view class="pro-btn">立即购买</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="product2 ddflex" v-if="item.value.layoutNum == 2">
  61. <view class="li" v-for="(it,idx) in item.value.productList" :key="idx" @click="jumpUrl('/product/detail/detail?id=' + it.id)">
  62. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  63. <view class="pro-info fflex">
  64. <view class="pro-name tovers">{{it.title}}</view>
  65. <view class="pro-opt ddflex">
  66. <view class="money">¥{{it.minSalePrice}}<text>/起</text></view>
  67. <view class="pro-cart"><image src="../../static/pages/images/jia.png"></image></view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="product product3" v-if="item.value.layoutNum == 3">
  73. <scroll-view scroll-x="true">
  74. <view class="li" v-for="(it,idx) in item.value.productList" :key="idx" @click="jumpUrl('/product/detail/detail?id=' + it.id)">
  75. <view class="ddflex">
  76. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  77. <view class="pro-info fflex">
  78. <view class="pro-name tovers">{{it.title}}</view>
  79. <view class="pro-bri tover" v-if="it.brief">{{it.brief}}</view>
  80. <view class="pro-opt ddflex">
  81. <view class="money">¥{{it.minSalePrice}}<text>/起</text></view>
  82. <view class="pro-btn">立即购买</view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </scroll-view>
  88. </view>
  89. </block>
  90. <block v-if="item.key == 'images'">
  91. <view class="images" v-if="index == 0">
  92. <image :src="item.value.src" mode="widthFix"></image>
  93. <view class="img-bot ddflex">
  94. <view class="bot-free" style="background: none;" @tap="redirectUrl('pages/index/index')"></view>
  95. <view class="bot-lx" style="background: none;" @tap="callPhone('15173158288')"></view>
  96. </view>
  97. </view>
  98. <view class="images" v-else>
  99. <image :src="item.value.src" mode="widthFix"></image>
  100. </view>
  101. </block>
  102. <block v-if="item.key == 'customerService'"></block>
  103. <button open-type="contact" class="contact ddflex" v-if="item.value.type == '0'">
  104. <image src="../../static/pages/images/kfico.png"></image>客服
  105. </button>
  106. <view class="contact ddflex" @click="customerServiceChat(item.value)" v-if="item.value.type == '1'">
  107. <image src="../../static/pages/images/kfico.png"></image>客服
  108. </view>
  109. <view class="contact ddflex" @click="jumpHref(item.value)" v-if="item.value.type == '2'">
  110. <image src="../../static/pages/images/kfico.png"></image>客服
  111. </view>
  112. </block>
  113. <view class="bots">
  114. <view class="bot-title">{{params.title}}</view>
  115. <view class="bots-btn" @click="redirectUrl('pages/index/index?isJump=true')">立即体验</view>
  116. </view>
  117. <!-- <block v-if="isShowBot">
  118. <view style="height: 138rpx;"></view>
  119. <view class="bott ddflex">
  120. <view class="bot-free" @click="redirectUrl('pages/index/index')">免费体验</view>
  121. <view class="bot-lx" @click="callPhone('15173158288')">联系私域专家</view>
  122. </view>
  123. </block> -->
  124. </view>
  125. </template>
  126. <script>
  127. const app = getApp();
  128. const req = require("../../utils/request.js");
  129. import vShare from "../../components/share/share";
  130. export default {
  131. components: {
  132. vShare
  133. },
  134. data() {
  135. return {
  136. picUrlss: req.public.picUrls,
  137. systems: {},
  138. isTop: 0,
  139. options:{},
  140. params: '',
  141. swiperCurrent: 0,
  142. hideShare: true,
  143. codeUrl: '',
  144. sessionKey: '',
  145. openid: '',
  146. userInfo: {},
  147. saveId: '',
  148. config: '',
  149. isShowBot: false,
  150. isShowPage: false
  151. };
  152. },
  153. async onLoad(options) {
  154. req.removeStorage('AUTH_TOKEN');
  155. req.removeStorage('appId');
  156. await req.setStorage('appId',options.appId);
  157. this.options = options;
  158. req.removeStorage('userInfo');
  159. req.removeStorage('configRes');
  160. req.setStorage('pidCode',options.userId)
  161. req.silenceLogin(options.userId, '');
  162. await this.getConfig();
  163. await this.getParams();
  164. await this.saveBehavior(4);
  165. },
  166. onShow() {
  167. },
  168. onUnload() {
  169. },
  170. methods: {
  171. getConfig(){
  172. return new Promise((resolve, reject) => {
  173. req.getRequest('/api/config',{},data=>{
  174. this.config = data;
  175. app.globalData.upColor();
  176. resolve();
  177. })
  178. })
  179. },
  180. getParams() {
  181. let that = this;
  182. let params = {
  183. code: this.config.sharePage_code
  184. }
  185. return new Promise((resolve, reject) => {
  186. req.getRequest('/api/v3/material/library/detail', params, data => {
  187. data.params.jsonContent.map(item=>{
  188. if(item.key == 'applicationForm'){
  189. item.value.formItemList.map(it=>{
  190. if(it.label.indexOf('姓名')>-1){
  191. if(that.userInfo.nickName){
  192. it.fieldValue = that.userInfo.nickName
  193. }
  194. }
  195. if(it.dataType == 1){
  196. if(that.userInfo.mobile){
  197. it.fieldValue = that.userInfo.mobile
  198. }
  199. }
  200. if(it.type == 5){
  201. it.option = ['大健康','快销品']
  202. }
  203. })
  204. }
  205. return item
  206. })
  207. that.params = data
  208. uni.setNavigationBarTitle({
  209. title: data.title
  210. })
  211. that.isShowPage = true;
  212. resolve();
  213. });
  214. });
  215. },
  216. saveBehavior(behavior){
  217. let params = {
  218. behavior: behavior,
  219. type: 7,
  220. bindId: this.params.libraryId
  221. }
  222. if(req.getStorage('pidCode')){
  223. params.pid = req.getStorage('pidCode')
  224. }
  225. if(this.saveId){
  226. params.parentId = this.saveId
  227. }
  228. req.saveBehavior(params,data=>{
  229. if(behavior != 6){
  230. this.saveId = data
  231. }
  232. })
  233. },
  234. updateBehavior(){
  235. let params = {
  236. id: this.saveId
  237. }
  238. req.getBehaviorUpdate(params,data=>{})
  239. },
  240. swiperChange(e) {
  241. this.swiperCurrent = e.detail.current;
  242. },
  243. jumpUrl(url){
  244. uni.navigateTo({
  245. url: url
  246. })
  247. },
  248. customerServiceChat(item) {
  249. wx.openCustomerServiceChat({
  250. extInfo: {
  251. url: item.target
  252. },
  253. corpId: item.id,
  254. success(res) {
  255. console.log('调用微信客服')
  256. }
  257. })
  258. },
  259. jumpHref(item){
  260. window.location.href = item.target
  261. },
  262. showShare() {
  263. // #ifdef H5
  264. this.hideShare = false
  265. // #endif
  266. // #ifndef H5
  267. req.isLogin().then(success => {
  268. if (success) {
  269. this.getCodeUrl()
  270. this.hideShare = false
  271. }
  272. });
  273. // #endif
  274. },
  275. click(e) {
  276. this.hideShare = e
  277. },
  278. getCodeUrl() {
  279. let that = this;
  280. let scene = that.params.code;
  281. if(req.getStorage('appId')) scene += '_'+ req.getStorage('appId');
  282. const params = {
  283. page: 'leaflet/detail/index',
  284. scene: scene
  285. };
  286. req.getRequest('/api/program/codev', params, url => {
  287. that.codeUrl = url
  288. });
  289. },
  290. loadCodeParams() {
  291. let _ts = this;
  292. return new Promise((resolve, reject) => {
  293. let form = {
  294. scene: _ts.options.scene
  295. };
  296. if (!_ts.options.scene) {
  297. resolve();
  298. return false;
  299. }
  300. req.getRequest('/api/code/params', form, data => {
  301. let res = data.scene.split('_');
  302. this.options.code = res[0];
  303. req.setStorage('pidCode', data.userId);
  304. req.silenceLogin(data.userId, '');
  305. req.setStorage('appId',res[res.length-1]);
  306. resolve();
  307. });
  308. });
  309. },
  310. getPhoneNumber(e) {
  311. console.log('获取手机号',e)
  312. let that = this;
  313. let _params = {
  314. sessionKey: that.sessionKey,
  315. iv: e.detail.iv,
  316. encryptedData: e.detail.encryptedData
  317. };
  318. if (req.getStorage('pidCode')) {
  319. _params.parentId = req.getStorage('pidCode');
  320. }
  321. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  322. req.postRequest('/api/weixin/mobile', _params, json => {
  323. // console.log(json);
  324. if (json.mobile) {
  325. var userInfo = req.getStorage('userInfo');
  326. userInfo.mobile = json.mobile;
  327. req.setStorage('userInfo', userInfo);
  328. that.params.params.jsonContent.map(item=>{
  329. if(item.key == 'applicationForm'){
  330. item.value.formItemList.map(it=>{
  331. if(it.dataType == 1){
  332. it.fieldValue = json.mobile
  333. }
  334. })
  335. }
  336. return item
  337. })
  338. that.$forceUpdate();
  339. }
  340. });
  341. }
  342. },
  343. changeOptions(e,idx){
  344. console.log('选择==',e)
  345. console.log('idx==',idx)
  346. this.params.params.jsonContent.map(item=>{
  347. if(item.key == 'applicationForm'){
  348. item.value.formItemList.map((it,index)=>{
  349. if(it.type == 5&&idx==index){
  350. it.fieldValue = it.option[e.detail.value]
  351. }
  352. })
  353. }
  354. return item
  355. })
  356. this.$forceUpdate()
  357. },
  358. checkRequire(formItemList){
  359. for(var i = 0; i < formItemList.length; i++){
  360. if(formItemList[i].required){
  361. if(!formItemList[i].fieldValue){
  362. req.msg('请填写' + formItemList[i].label);
  363. return false;
  364. }
  365. }
  366. }
  367. return true;
  368. },
  369. formSubmit(datas){
  370. let params = {
  371. formId: datas.database,
  372. libraryId: this.params.libraryId
  373. }
  374. if(req.getStorage('userInfo').id){
  375. params.belongUid = req.getStorage('userInfo').id
  376. }
  377. let formItemList = datas.formItemList
  378. let valueList = []
  379. if(!this.checkRequire(formItemList)) return false
  380. formItemList.map(it=>{
  381. let obj = {
  382. fieldId: it.databaseLabel,
  383. fieldName: it.label,
  384. fieldType: it.type,
  385. fieldValue: it.fieldValue
  386. }
  387. valueList.push(obj)
  388. })
  389. params.valueList = valueList;
  390. console.log('表单提交==',params)
  391. req.postRequest('/api/v3/custom/form/submit',params,data=>{
  392. req.alertMsg('你的信息已成功提交,会有专业人员联系你,请耐心等待',suc=>{
  393. this.getParams();
  394. })
  395. })
  396. },
  397. callPhone(phone){
  398. uni.makePhoneCall({
  399. phoneNumber: phone
  400. })
  401. },
  402. redirectUrl(url){
  403. req.removeStorage('configRes');
  404. req.removeStorage('defaultMerchant');
  405. req.removeStorage('MERCHANT');
  406. req.removeStorage('loctionAddressMap');
  407. req.setStorage('configRes',this.config);
  408. uni.showLoading({
  409. title: '正在加载配置'
  410. })
  411. setTimeout(res=>{
  412. uni.hideLoading();
  413. app.globalData.redirectTab(url);
  414. },2000)
  415. }
  416. },
  417. mounted() {
  418. const systemInfo = uni.getSystemInfoSync();
  419. // px转换到rpx的比例
  420. let pxToRpxScale = 750 / systemInfo.windowWidth;
  421. let systems = {
  422. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  423. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  424. };
  425. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  426. this.systems = systems;
  427. },
  428. onPageScroll: function(e) {
  429. if(e.scrollTop > 810){
  430. this.isShowBot = true;
  431. }else{
  432. this.isShowBot = false;
  433. }
  434. if (e.scrollTop > this.systems.barHeight) {
  435. this.isTop = 1;
  436. } else {
  437. this.isTop = 0;
  438. }
  439. }
  440. };
  441. </script>
  442. <style>
  443. @import './index.css';
  444. </style>