index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view>
  3. <view class="top" :style="'height:'+systems.barHeight+'rpx;'">
  4. <view :class="'top-bg'+(isFixed?' top-bg-fix':'')"></view>
  5. <view class="top-c" :style="'height:'+systems.navigationHeight+'rpx;margin-top:'+systems.ktxStatusHeight+'rpx;'">
  6. <image :src="picUrlss+'lvluo/home_logo.png'" class="logo"></image>
  7. </view>
  8. </view>
  9. <view class="banner">
  10. <image :src="picUrlss+'lvluo/home_top_img.png'"></image>
  11. </view>
  12. <block v-if="faList.length>0">
  13. <!-- <view class="tit">应用方案</view> -->
  14. <view class="fa-list ddflex">
  15. <view class="li ddflex" v-for="(item,index) in faList" :key="index" @click="jumpUrl(item,1)">
  16. <view>{{item.title}}</view>
  17. <image :src="item.pic"></image>
  18. </view>
  19. </view>
  20. </block>
  21. <simple-phone v-if="isShowPhonePop" @closePop="closePop"></simple-phone>
  22. </view>
  23. </template>
  24. <script>
  25. const app = getApp();
  26. const req = require('../../utils/request.js');
  27. var timer; //定时器状态
  28. // let WebIM = (wx.WebIM = require("../../hxChatSDK/utils/WebIM")["default"]);
  29. export default {
  30. data() {
  31. return {
  32. picUrlss: req.public.picUrls,
  33. systems: {},
  34. pxToRpxScale: 0,
  35. isFixed: false,
  36. faList: [],
  37. caseList: [],
  38. config: '',
  39. isShowPhonePop: false
  40. };
  41. },
  42. onLoad: async function(options) {
  43. req.removeStorage('AUTH_TOKEN');
  44. req.removeStorage('appId');
  45. req.removeStorage('userInfo');
  46. await req.setStorage('appId',req.env.NODE_ENV == 'prd' ? 'ZQKmmjlYyTRmssC' : 'ZQ4KaYIMHTypO0T');
  47. await this.getFaList();
  48. await this.getConfig();
  49. if(options.userId) req.setStorage('pidCode',options.userId);
  50. let sceneId = req.getStorage('scene');
  51. await req.silenceLogin(options.userId,'',sceneId == 1065 ? 14 : '');
  52. let phone = req.getStorage('userInfo').mobile;
  53. if(sceneId == 1065){
  54. if(!phone && this.config.is_show_scheme_pop == 1) this.getPhonePop();//通过scheme进入
  55. }
  56. // await this.getCaseList();
  57. },
  58. onShow() {
  59. },
  60. onShareAppMessage: function() {
  61. return {
  62. title: this.getShareTitle(),
  63. path: this.getSharePath()
  64. };
  65. },
  66. onShareTimeline() {
  67. return {
  68. title: this.getShareTitle(),
  69. query: this.getSharePath()
  70. };
  71. },
  72. methods: {
  73. getPhonePop(){
  74. this.isShowPhonePop = true;
  75. },
  76. closePop(){
  77. this.isShowPhonePop = false;
  78. },
  79. getConfig(){
  80. return new Promise((resolve,reject)=>{
  81. req.getRequest('/api/config',{},data=>{
  82. this.config = data;
  83. resolve();
  84. })
  85. })
  86. },
  87. getFaList(){
  88. uni.showLoading();
  89. return new Promise((resolve,reject)=>{
  90. req.getRequest('/api/content/list',{code: 'yyfa'},data=>{
  91. this.faList = data;
  92. uni.hideLoading();
  93. resolve();
  94. })
  95. })
  96. },
  97. getCaseList(){
  98. return new Promise((resolve,reject)=>{
  99. req.getRequest('/api/content/list',{code: 'yyal'},data=>{
  100. this.caseList = data;
  101. uni.hideLoading();
  102. resolve();
  103. })
  104. })
  105. },
  106. getSharePath() {
  107. let path = '/pages/home/index?isShare=' + true;
  108. if (req.getStorage('userInfo')) {
  109. path += '&userId=' + req.getStorage('userInfo').id;
  110. }
  111. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  112. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  113. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  114. path += '&shopId=' + req.getStorage('smallShop').id;
  115. }
  116. }
  117. return path;
  118. },
  119. getShareTitle() {
  120. let title = '';
  121. if (this.merchant && this.merchant.title && this.merchant.title != '默认门店') {
  122. title = this.merchant.title;
  123. } else {
  124. title = this.config.CONFIG_PROJECT_TITLE;
  125. }
  126. return (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage('userInfo').nickName) : '') + '为你推荐' + title;
  127. },
  128. jumpUrl(item,type){
  129. if(type == 1){
  130. if(item.brief !== req.getStorage('appId')){
  131. req.removeStorage('appId');
  132. req.removeStorage('userInfo');
  133. req.removeStorage('configRes');
  134. req.removeStorage('defaultMerchant');
  135. req.removeStorage('MERCHANT');
  136. req.removeStorage('loctionAddressMap');
  137. req.setStorage('appId',item.brief);
  138. }
  139. req.removeStorage('imToken')
  140. uni.removeStorageSync('myUsername')
  141. uni.showLoading({
  142. title: '正在加载配置'
  143. })
  144. req.getRequest('/api/config',{},data=>{
  145. console.log("切换案例",data)
  146. req.setStorage('configRes',JSON.stringify(data));
  147. app.globalData.upColor(true)
  148. // this.onClosed()
  149. setTimeout(res=>{
  150. uni.hideLoading();
  151. app.globalData.reLaunchTo('pages/index/index');
  152. },2000)
  153. })
  154. }else{
  155. uni.navigateToMiniProgram({
  156. appId: item.brief,
  157. path: item.fieldValues.homepage?item.fieldValues.homepage:'pages/index/index',
  158. envVersion: req.env.NODE_ENV == 'product' ? 'release' : 'trial'
  159. });
  160. }
  161. },
  162. // onClosed() {
  163. // // uni.showToast({
  164. // // title: "退出登录",
  165. // // icon: "none",
  166. // // duration: 2000,
  167. // // });
  168. // console.log('>>>>>>>>>>>IM被退出登录>>>>>>>>>>>>>>>>>')
  169. // // uni.redirectTo({
  170. // // url: "../login/login",
  171. // // });
  172. // app.globalData.conn.closed = true;
  173. // WebIM.conn.close();
  174. // },
  175. },
  176. beforeMount() {
  177. const systemInfo = uni.getSystemInfoSync();
  178. // px转换到rpx的比例
  179. let pxToRpxScale = 750 / systemInfo.windowWidth;
  180. this.pxToRpxScale = pxToRpxScale;
  181. let systems = {
  182. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  183. navigationHeight: 44 * pxToRpxScale, // 导航栏的高度
  184. };
  185. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  186. this.systems = systems;
  187. },
  188. onPageScroll(e) {
  189. if(e.scrollTop > this.systems.barHeight/this.pxToRpxScale){
  190. this.isFixed = true;
  191. }else{
  192. this.isFixed = false;
  193. }
  194. },
  195. };
  196. </script>
  197. <style>
  198. @import './index.css';
  199. </style>