index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <template>
  2. <view id="topId">
  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. <navigator url="" hover-class="none" open-type="navigateBack" class="back"><image :src="picUrlss+'back_black.png'"></image></navigator>
  7. <view class="top-title tover" :style="'line-height: '+ systems.navigationHeight + 'rpx;'" v-if="isTop == 1">{{params.title}}</view>
  8. </view>
  9. </view>
  10. <view :style="'height:'+(systems.barHeight?systems.barHeight:44)+'rpx;'"></view> -->
  11. <view class="side" :class="specClassSide" @tap="showSide">
  12. <image src="../static/images/share_close.png" class="share-close" @click.stop="hideSide"></image>
  13. <view class="share" @tap="showShare()"><image src="../static/images/share_img.png"></image></view>
  14. </view>
  15. <view id="topId">
  16. <!-- <view class="title">{{ params.title }}</view> -->
  17. <!-- <view class="det-sta ddflex">
  18. <view class="sort" v-if="params.cateName">{{params.cateName}}</view>
  19. <view class="sort-line" v-if="params.cateName"></view>
  20. <view class="time" style="color: #5B698F;">
  21. {{(params.user && params.user.nickName)?params.user.nickName:config.CONFIG_PROJECT_TITLE}}
  22. </view>
  23. <view class="time" style="margin-left: 10rpx;">
  24. {{formatTime(params.createDate)}}
  25. </view>
  26. </view> -->
  27. <view :class="'viewMore' + (viewMoress?' con-vheight':'')" :style="'max-height:' + height">
  28. <block v-for="(item,index) in params.params.jsonContent" :key="index">
  29. <view class="ban" v-if="item.key == 'banner'">
  30. <swiper class="swiper" @change="swiperChange" autoplay="true" interval="5000" duration="300">
  31. <block v-for="(it, idx) in item.value.imageList" :key="idx">
  32. <swiper-item>
  33. <image lazy-load="true" :src="it.src" mode="aspectFill" @click="clickBanner(item)"></image>
  34. </swiper-item>
  35. </block>
  36. </swiper>
  37. <view class="dots ddflex">
  38. <block v-for="(it, idx) in item.value.imageList" :key="idx"><view :class="['dot', idx == swiperCurrent ? 'active' : '']"></view></block>
  39. </view>
  40. </view>
  41. <view class="form" v-if="item.key == 'applicationForm'" :id="item.elementId">
  42. <view class="form-title" v-if="item.value.title.isShow">{{item.value.title.value}}</view>
  43. <view class="form-list">
  44. <view class="li" v-for="(it,idx) in item.value.formItemList" :key="idx">
  45. <view class="label">{{it.label}}</view>
  46. <block v-if="it.type == 1">
  47. <button open-type="getPhoneNumber" hover-class="none" @getphonenumber="getPhoneNumber" :class="'phone-ipt fflex' + (it.fieldValue?'':' placeholder')" v-if="it.dataType == 1">
  48. <block v-if="it.fieldValue">{{it.fieldValue}}</block>
  49. <block v-else>请填写{{it.label}}</block>
  50. </button>
  51. <input v-model="it.fieldValue" :placeholder="'请填写' + it.label" placeholder-class="placeholder" class="ipt fflex" v-else />
  52. </block>
  53. <textarea v-model="it.fieldValue" :placeholder="'请填写' + it.label" placeholder-class="placeholder" class="textarea fflex" v-else-if="it.type == 4"></textarea>
  54. <picker :range="it.option" class="pickers fflex" @change="changeOptions($event,idx)" v-else-if="it.type == 5">
  55. <view v-if="it.fieldValue">{{it.fieldValue}}</view>
  56. <view class="placeholder" v-else>请选择{{it.label}}</view>
  57. </picker>
  58. </view>
  59. </view>
  60. <view class="form-btn" @click="formSubmit(item.value)">{{item.value.buttonName}}</view>
  61. </view>
  62. <view class="richText" v-if="item.key == 'text'">
  63. <rich-text :nodes="item.value.content"></rich-text>
  64. </view>
  65. <block v-if="item.key == 'product'">
  66. <view class="product" v-if="item.value.layoutNum == 1">
  67. <view class="li ddflex" v-for="(it,idx) in item.value.productList" :key="idx" @click="jumpUrl('/product/detail/detail?id=' + it.id)">
  68. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  69. <view class="pro-info fflex">
  70. <view class="pro-name tovers">{{it.title}}</view>
  71. <view class="pro-bri tover" v-if="it.brief">{{it.brief}}</view>
  72. <view class="pro-opt ddflex">
  73. <view class="money">¥{{it.minSalePrice}}<text>/起</text></view>
  74. <view class="pro-btn">立即购买</view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="product2 ddflex" v-if="item.value.layoutNum == 2">
  80. <view class="li" v-for="(it,idx) in item.value.productList" :key="idx" @click="jumpUrl('/product/detail/detail?id=' + it.id)">
  81. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  82. <view class="pro-info fflex">
  83. <view class="pro-name tovers">{{it.title}}</view>
  84. <view class="pro-opt ddflex">
  85. <view class="money">¥{{it.minSalePrice}}<text>/起</text></view>
  86. <view class="pro-cart"><image src="../../static/pages/images/jia.png"></image></view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="product product3" v-if="item.value.layoutNum == 3">
  92. <scroll-view scroll-x="true">
  93. <view class="li" v-for="(it,idx) in item.value.productList" :key="idx" @click="jumpUrl('/product/detail/detail?id=' + it.id)">
  94. <view class="ddflex">
  95. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  96. <view class="pro-info fflex">
  97. <view class="pro-name tovers">{{it.title}}</view>
  98. <view class="pro-bri tover" v-if="it.brief">{{it.brief}}</view>
  99. <view class="pro-opt ddflex">
  100. <view class="money">¥{{it.minSalePrice}}<text>/起</text></view>
  101. <view class="pro-btn">立即购买</view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </scroll-view>
  107. </view>
  108. </block>
  109. <view class="images" v-if="item.key == 'images'">
  110. <image :src="item.value.src" mode="widthFix"></image>
  111. </view>
  112. <block v-if="item.key == 'customerService'"></block>
  113. <button open-type="contact" class="contact ddflex" v-if="item.value.type == '0'">
  114. <image src="../../static/pages/images/kfico.png"></image>客服
  115. </button>
  116. <view class="contact ddflex" @click="customerServiceChat(item.value)" v-if="item.value.type == '1'">
  117. <image src="../../static/pages/images/kfico.png"></image>客服
  118. </view>
  119. <view class="contact ddflex" @click="jumpHref(item.value)" v-if="item.value.type == '2'">
  120. <image src="../../static/pages/images/kfico.png"></image>客服
  121. </view>
  122. </block>
  123. </view>
  124. <!-- <view class="view-more" @tap="viewMores()" v-if="viewMoress">查看全文</view> -->
  125. <!-- <view class="bottom-info">
  126. <view class="bottom-info-browse">浏览 {{params.browseCount}}</view>
  127. <view style="margin-top: 20rpx;">
  128. <view class="ddflex">
  129. <image class="bottom-info-logo" :src="config.CONFIG_PROJECT_LOGO"></image>
  130. <view class="fflex">{{config.CONFIG_PROJECT_TITLE}}</view>
  131. <view class="bottom-info-option" @click="showShare">
  132. <image style="width: 32rpx;height: 32rpx;margin: auto;" src="../static/images/share.png"></image>
  133. <view>分享</view>
  134. </view>
  135. <view class="bottom-info-option" style="margin-left: 50rpx;">
  136. <image style="width: 32rpx;height: 32rpx;margin: auto;" src="../static/images/dz.png"></image>
  137. <view>99+</view>
  138. </view>
  139. </view>
  140. </view>
  141. </view> -->
  142. <!-- <view class="guwen ddflex" v-if="cardInfo" @click="jumpUrl('/card/index/index?cardId='+cardInfo.id)">
  143. <image :src="picUrlss+'lvluo/home_guwen.png'" class="guwen-img"></image>
  144. <view class="fflex">
  145. <view class="ddflex">
  146. <image :src="cardInfo.imageMap?cardInfo.imageMap:picUrlss+'lvluo/hulei.png'" class="guwen-user"></image>
  147. <view class="fflex">
  148. <view class="guwen-name ddflex">{{cardInfo&&cardInfo.realName?cardInfo.realName:'胡雷'}}</view>
  149. <text class="guwen-tag">{{cardInfo&&cardInfo.job?cardInfo.job:'绿萝云-诊所私域专家'}}</text>
  150. <view class="guwen-mobile">{{cardInfo&&cardInfo.phone?cardInfo.phone:'15173158288'}}</view>
  151. </view>
  152. </view>
  153. </view>
  154. <view class="guwen-ewm">
  155. <image :src="cardInfo.qrCode?cardInfo.qrCode:picUrlss+'lvluo/wechat.png'" show-menu-by-longpress="true"></image>
  156. <view>长按扫码添加微信</view>
  157. </view>
  158. </view> -->
  159. <view style="height: 100rpx;" v-if="anchorId"></view>
  160. <view class="bottom-option ddflex" v-if="anchorId">
  161. <view class="ddflex" @click="jumpSingleChatRoom()">
  162. <image style="width: 37rpx;height: 38rpx;margin-right: 17rpx;" src="/martial/static/images/kf.png"></image>
  163. <view>联系客服</view>
  164. </view>
  165. <view class="bottom-option-line"></view>
  166. <view class="ddflex" @click="anchor(anchorId)">
  167. <image style="width: 36rpx;height: 38rpx;margin-right: 17rpx;" src="/martial/static/images/bd.png"></image>
  168. <view>填写表单</view>
  169. </view>
  170. </view>
  171. </view>
  172. <!--
  173. <view class="share ddflex" @click="showShare">
  174. <image src="../../static/pages/images/fxico1_1.png"></image>分享
  175. </view> -->
  176. <view @click="jumpSingleChatRoom()" class="contact-nav ddflex" v-if="advisor&&advisor.id">
  177. <image :src="advisor.headUrl ? advisor.headUrl : picUrlss+'lvluo/fixed_img.png'" mode="aspectFill"></image>
  178. <view class="contact-text"><view class="tover"><!-- {{advisor.realName}} -->服务</view><text>顾问</text></view>
  179. <!-- <view v-if="unReadSpotNum>0" class="newsDot"></view> -->
  180. </view>
  181. <!--#ifndef H5-->
  182. <v-share ref="vshare" :hide-toast="hideShare" :product="params" type="market" :code-url="codeUrl" @onFather="click"></v-share>
  183. <!-- #endif -->
  184. <!-- #ifdef H5 -->
  185. <view class="share-pop" @click="hideSharePop" v-if="isShowSharePop">
  186. <image src="../static/images/fx-tip1.png"></image>
  187. </view>
  188. <wx-share ref="wxshare" />
  189. <!-- #endif -->
  190. </view>
  191. </template>
  192. <script>
  193. const app = getApp();
  194. const req = require("../../utils/request.js");
  195. import vShare from "../../components/share/share";
  196. const util = require("../../utils/util.js");
  197. var timer = ''
  198. export default {
  199. components: {
  200. vShare
  201. },
  202. data() {
  203. return {
  204. picUrlss: req.public.picUrls,
  205. systems: {},
  206. isTop: 0,
  207. config:{},
  208. options:{},
  209. params: '',
  210. swiperCurrent: 0,
  211. codeUrl: '',
  212. sessionKey: '',
  213. openid: '',
  214. userInfo: {},
  215. saveId: '',
  216. viewMoress: false,
  217. height: 'initial',
  218. cardInfo:'',
  219. advisor:'',
  220. anchorId:'',
  221. specClassSide: 'hide-side',
  222. hideShare: true,
  223. isShowSharePop: false,
  224. code: '',
  225. rootCode: '',
  226. };
  227. },
  228. async onLoad(options) {
  229. if(options.appId) req.setStorage('appId',options.appId);
  230. this.options = options;
  231. if(options.userId){
  232. req.setStorage('pidCode',options.userId)
  233. }
  234. if(options.saveBehaviorId){
  235. this.saveId = options.saveBehaviorId
  236. }
  237. app.globalData.getCheckSessoin(json => {
  238. this.sessionKey = json.session_key;
  239. this.openid = json.openid;
  240. });
  241. if(options.scene || options.x_code_id){
  242. await this.loadCodeParams();
  243. }
  244. this.PAGE_DATA_INIT_FN({
  245. BIND_ID:this.options.code
  246. })
  247. await req.silenceLogin(this.options.userId, '');
  248. this.code = options.code;
  249. this.rootCode = options.rootCode
  250. this.getConfig()
  251. await this.getParams();
  252. // if(this.options.userId){
  253. // // 查询分享人名片
  254. // await this.getCardInfo()
  255. // }
  256. // this.$nextTick(()=>{
  257. // this.monitor();
  258. // })
  259. await this.saveBehavior(4);
  260. },
  261. onShow() {
  262. this.userInfo = req.getStorage('userInfo');
  263. // if(this.options.userId)
  264. // this.getCardInfo()
  265. this.getAdvisor()
  266. },
  267. onUnload() {
  268. this.updateBehavior()
  269. },
  270. async onShareAppMessage() {
  271. var content = await this.onShareMessage();
  272. this.SEND_SHARE_FN()
  273. return content;
  274. },
  275. onShareTimeline() {
  276. this.saveBehavior(6)
  277. let path = {
  278. code: this.params.code,
  279. appId: req.getStorage('appId')
  280. }
  281. if(req.getStorage('userInfo').id){
  282. path.userId = req.getStorage('userInfo').id
  283. }
  284. if(this.saveId){
  285. path += '&saveBehaviorId=' + this.saveId
  286. }
  287. return {
  288. title: this.params.title,
  289. query: path,
  290. imageUrl: this.params.pic
  291. };
  292. },
  293. onReady() {
  294. // #ifdef H5
  295. var that = this;
  296. //初始化分享内容
  297. setTimeout(function() {
  298. var shareContent = that.onShareMessage();
  299. if (shareContent) {
  300. shareContent.path = window.location.origin + shareContent.path;
  301. }
  302. console.log('分享内容》》》》》', shareContent);
  303. that.$refs.wxshare.init(shareContent);
  304. }, 4 * 1000);
  305. // #endif
  306. },
  307. methods: {
  308. getConfig() {
  309. req.getRequest('/api/config', {}, res => {
  310. this.config = res
  311. })
  312. },
  313. async onShareMessage(options) {
  314. let isSolution = '';
  315. let path = '';
  316. // #ifndef H5
  317. isSolution = req.env[req.env.NODE_ENV].isSolution;
  318. // #endif
  319. // #ifdef H5
  320. isSolution = false;
  321. // #endif
  322. let userInfo = req.getStorage('userInfo');
  323. if (isSolution) {
  324. path = '/share/home/index?appId=' + req.getStorage('appId') + '&userId=' + req.getStorage(
  325. 'userInfo').id;
  326. } else {
  327. let page = getCurrentPages()
  328. let pageCurrent = page[page.length-1]
  329. path = pageCurrent.route+'?code=' + this.code + '&rootCode=' + this.rootCode + '&isShare=' + true + '&appId=' + req
  330. .getStorage('appId');
  331. // console.log(!req.getStorage('userInfo').id);
  332. if (!userInfo.id) {} else {
  333. path += '&userId=' + userInfo.id;
  334. }
  335. path = this.SHARE_BEHAVIOR_FN({path:path,sendShare:false}).path
  336. }
  337. console.log({
  338. title: this.params.title,
  339. imageUrl: this.params.pic,
  340. path: path
  341. })
  342. return {
  343. title: this.params.title,
  344. imageUrl: this.params.pic,
  345. path: path
  346. };
  347. },
  348. showShare() {
  349. // #ifdef H5
  350. this.hideShare = false;
  351. this.showSharePop();
  352. console.log('引导分享==')
  353. // #endif
  354. // #ifndef H5
  355. req.isLogin().then(success => {
  356. if (success) {
  357. this.getCodeUrl()
  358. this.hideShare = false
  359. }
  360. });
  361. this.$refs.vshare.chnageHideToast()
  362. // #endif
  363. },
  364. showSharePop() {
  365. this.isShowSharePop = true;
  366. },
  367. hideSharePop() {
  368. this.isShowSharePop = false;
  369. },
  370. getAdvisor() {
  371. return new Promise((resolve, reject) => {
  372. req.getRequest('/api/distribution/advisorInfo', {}, data => {
  373. console.log('服务顾问==', data)
  374. this.advisor = data;
  375. resolve();
  376. })
  377. })
  378. },
  379. jumpSingleChatRoom() {
  380. // if (!this.getUpdate()) return false;
  381. // if (this.advisor) {
  382. // req.jumpSingleChatRoom(this.advisor.id, this.advisor.headUrl, this.advisor
  383. // .realName);
  384. // }
  385. // #ifdef H5
  386. if(!req.isLogins(true)) return false
  387. // #endif
  388. this.jumpUrl('/other/contact/index')
  389. },
  390. // 锚点
  391. anchor(id) {
  392. console.log(id)
  393. this.$nextTick(() => {
  394. setTimeout(() => {
  395. uni.createSelectorQuery().select('#topId').boundingClientRect(data => {
  396. uni.createSelectorQuery().select("#" + id).boundingClientRect(res => {
  397. if(res){
  398. uni.pageScrollTo({
  399. duration: 100, //过渡时间
  400. scrollTop: res.top - data.top -
  401. 100, //返回顶部的top值
  402. success: () => {
  403. }
  404. })
  405. }
  406. }).exec()
  407. }).exec();
  408. }, 50)
  409. })
  410. },
  411. getParams() {
  412. let that = this;
  413. let params = {
  414. code: this.options.code
  415. }
  416. return new Promise((resolve, reject) => {
  417. req.getRequest('/api/v3/material/library/detail', params, data => {
  418. uni.setNavigationBarTitle({
  419. title:params.title
  420. })
  421. data.params.jsonContent.map((item,index)=>{
  422. if(item.key == 'applicationForm'){
  423. item.value.formItemList.map(it=>{
  424. if(it.label.indexOf('姓名')>-1){
  425. if(that.userInfo.nickName){
  426. it.fieldValue = that.userInfo.nickName
  427. }
  428. }
  429. if(it.dataType == 1){
  430. if(that.userInfo.mobile){
  431. it.fieldValue = that.userInfo.mobile
  432. }
  433. }
  434. if(it.type == 5){
  435. it.option = ['大健康','快销品']
  436. }
  437. })
  438. item.elementId = item.key+index
  439. if(!this.anchorId) this.anchorId = item.elementId
  440. }
  441. return item
  442. })
  443. that.params = data
  444. uni.setNavigationBarTitle({
  445. title: data.title
  446. })
  447. console.log('data.title==',data.title)
  448. resolve();
  449. });
  450. });
  451. },
  452. saveBehavior(behavior){
  453. let params = {
  454. behavior: behavior,
  455. type: 7,
  456. bindId: this.params.libraryId
  457. }
  458. if(req.getStorage('pidCode')){
  459. params.pid = req.getStorage('pidCode')
  460. }
  461. if(this.saveId){
  462. params.parentId = this.saveId
  463. }
  464. req.saveBehavior(params,data=>{
  465. if(behavior != 6){
  466. this.saveId = data
  467. }
  468. })
  469. },
  470. updateBehavior(){
  471. let params = {
  472. id: this.saveId
  473. }
  474. req.getBehaviorUpdate(params,data=>{})
  475. },
  476. swiperChange(e) {
  477. this.swiperCurrent = e.detail.current;
  478. },
  479. jumpUrl(url){
  480. uni.navigateTo({
  481. url: url
  482. })
  483. },
  484. customerServiceChat(item) {
  485. wx.openCustomerServiceChat({
  486. extInfo: {
  487. url: item.target
  488. },
  489. corpId: item.id,
  490. success(res) {
  491. console.log('调用微信客服')
  492. }
  493. })
  494. },
  495. jumpHref(item){
  496. window.location.href = item.target
  497. },
  498. click(e) {
  499. this.hideShare = e
  500. console.log(this.hideShare)
  501. },
  502. getCodeUrl() {
  503. let that = this;
  504. let scene = that.params.code;
  505. if(req.getStorage('appId')) scene += '_'+ req.getStorage('appId');
  506. const params = {
  507. page: 'leaflet/detail/index',
  508. scene: scene
  509. };
  510. req.getRequest('/api/program/codev', params, url => {
  511. that.codeUrl = url
  512. });
  513. },
  514. loadCodeParams() {
  515. let _ts = this;
  516. return new Promise((resolve, reject) => {
  517. let form = {
  518. scene: _ts.options.scene?_ts.options.scene:_ts.options.x_code_id
  519. };
  520. if (!_ts.options.scene && !_ts.options.x_code_id) {
  521. resolve();
  522. return false;
  523. }
  524. req.getRequest('/api/code/params', form, data => {
  525. if(_ts.options.x_code_id){
  526. let res = JSON.parse(data.scene)
  527. for(let key in res){
  528. this.options[key] = res[key]
  529. }
  530. req.silenceLogin(_ts.options.userId, '');
  531. resolve();
  532. }else{
  533. let res = data.scene.split('_');
  534. this.options.code = res[0];
  535. req.setStorage('pidCode', data.userId);
  536. req.silenceLogin(data.userId, '');
  537. req.setStorage('appId',res[res.length-1]);
  538. resolve();
  539. }
  540. });
  541. });
  542. },
  543. getPhoneNumber(e) {
  544. console.log('获取手机号',e)
  545. let that = this;
  546. let _params = {
  547. sessionKey: that.sessionKey,
  548. iv: e.detail.iv,
  549. encryptedData: e.detail.encryptedData
  550. };
  551. if (req.getStorage('pidCode')) {
  552. _params.parentId = req.getStorage('pidCode');
  553. }
  554. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  555. req.postRequest('/api/weixin/mobile', _params, json => {
  556. // console.log(json);
  557. if (json.mobile) {
  558. var userInfo = req.getStorage('userInfo');
  559. userInfo.mobile = json.mobile;
  560. req.setStorage('userInfo', userInfo);
  561. that.params.params.jsonContent.map(item=>{
  562. if(item.key == 'applicationForm'){
  563. item.value.formItemList.map(it=>{
  564. if(it.dataType == 1){
  565. it.fieldValue = json.mobile
  566. }
  567. })
  568. }
  569. return item
  570. })
  571. that.$forceUpdate();
  572. }
  573. });
  574. }
  575. },
  576. changeOptions(e,idx){
  577. console.log('选择==',e)
  578. console.log('idx==',idx)
  579. this.params.params.jsonContent.map((item,index)=>{
  580. if(item.key == 'applicationForm'){
  581. item.value.formItemList.map((it,index)=>{
  582. if(it.type == 5&&idx==index){
  583. it.fieldValue = it.option[e.detail.value]
  584. }
  585. })
  586. }
  587. return item
  588. })
  589. this.$forceUpdate()
  590. },
  591. checkRequire(formItemList){
  592. for(var i = 0; i < formItemList.length; i++){
  593. if(formItemList[i].required){
  594. if(!formItemList[i].fieldValue){
  595. req.msg('请填写' + formItemList[i].label);
  596. return false;
  597. }
  598. }
  599. }
  600. return true;
  601. },
  602. formSubmit(datas){
  603. let params = {
  604. formId: datas.database,
  605. libraryId: this.params.libraryId
  606. }
  607. if(req.getStorage('userInfo').id){
  608. params.belongUid = req.getStorage('userInfo').id
  609. }
  610. let formItemList = datas.formItemList
  611. let valueList = []
  612. if(!this.checkRequire(formItemList)) return false
  613. formItemList.map(it=>{
  614. let obj = {
  615. fieldId: it.databaseLabel,
  616. fieldName: it.label,
  617. fieldType: it.type,
  618. fieldValue: it.fieldValue
  619. }
  620. valueList.push(obj)
  621. })
  622. params.valueList = valueList;
  623. console.log('表单提交==',params)
  624. req.postRequest('/api/v3/custom/form/submit',params,data=>{
  625. req.alertMsg('你的信息已成功提交,会有专业人员联系你,请耐心等待',suc=>{
  626. this.getParams();
  627. })
  628. })
  629. },
  630. callPhone(phone){
  631. uni.makePhoneCall({
  632. phoneNumber: phone
  633. })
  634. },
  635. monitor() {
  636. console.log('monitor')
  637. let that = this;
  638. let system = uni.getSystemInfoSync();
  639. let query = uni.createSelectorQuery();
  640. query.select('.viewMore').boundingClientRect(data=>{
  641. console.log('monitor data',data)
  642. if(data){
  643. let height = data.height*that.systems.pxToRpxScale;
  644. if(height > (system.windowHeight*that.systems.pxToRpxScale-30-that.systems.barHeight)) {
  645. that.height = (system.windowHeight*that.systems.pxToRpxScale-30-that.systems.barHeight-(this.cardInfo?650:300)) + 'rpx';
  646. that.viewMoress = true
  647. }
  648. }
  649. }).exec();
  650. },
  651. viewMores(){
  652. this.height = 'initial';
  653. this.viewMoress = false;
  654. },
  655. getCardInfo() {
  656. return new Promise((r,j)=>{
  657. var url = '';
  658. var dataP = {};
  659. url = '/api/v3/visiting/card/user';
  660. dataP.userId = this.options.userId;
  661. req.getRequest(url, dataP, data => {
  662. this.cardInfo = data;
  663. r()
  664. }, false);
  665. })
  666. },
  667. formatTime(time){
  668. let date = new Date(time.replace(/-/g,'/'))
  669. return util.formatTimeComm(date,'Y.M.D h:m')
  670. },
  671. showSide(){
  672. this.specClassSide = 'hide-side';
  673. },
  674. hideSide(){
  675. this.specClassSide = 'show-side';
  676. },
  677. },
  678. mounted() {
  679. const systemInfo = uni.getSystemInfoSync();
  680. // px转换到rpx的比例
  681. let pxToRpxScale = 750 / systemInfo.windowWidth;
  682. let systems = {
  683. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  684. navigationHeight: 44 * pxToRpxScale, // 导航栏的高度
  685. pxToRpxScale:pxToRpxScale
  686. };
  687. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  688. this.systems = systems;
  689. },
  690. onPageScroll: function(e) {
  691. if (e.scrollTop > this.systems.barHeight) {
  692. this.isTop = 1;
  693. } else {
  694. this.isTop = 0;
  695. }
  696. this.specClassSide = 'show-side';
  697. // 检测是否停留了 N 秒
  698. // 如果停留则表示滚动结束
  699. // N: 500(定时器时间 毫秒) -> 0.5秒算停止滚动
  700. // 滚动后多长时间算停止滚动
  701. timer = setTimeout(() => {
  702. // console.log('结束滚动');
  703. // 告知标识 -> 结束滚动
  704. this.specClassSide = 'hide-side';
  705. }, 500);
  706. this.$forceUpdate();
  707. }
  708. };
  709. </script>
  710. <style>
  711. @import './index.css';
  712. </style>