App.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <script>
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. import {
  12. checkLogin
  13. } from "./libs/login";
  14. import {
  15. HTTP_REQUEST_URL
  16. } from './config/app';
  17. import {
  18. getconfig,
  19. history
  20. } from '@/api/public.js'
  21. export default {
  22. globalData: {
  23. spid: 0,
  24. code: 0,
  25. isLogin: false,
  26. userInfo: {},
  27. MyMenus: [],
  28. balance_func_status: 0, //余额开关
  29. recharge_switch: 0, // 充值开关
  30. store_user_min_recharge: 0, //最小充值
  31. yue_pay_status: 0, //余额支付开关
  32. alipay_open: 0, //支付宝支付开关
  33. routine_logo: '', //首页logo
  34. site_logo: '',
  35. site_name: '', //名称
  36. fid: '', //一级分类id
  37. uid: '',
  38. hide_mer_status: 0,
  39. member_status: 0,
  40. copy_command_status: 0, //是否开启自动获取剪切板内容
  41. arrival_notice: 0, //是否开启到货通知
  42. is_phone_login: 0,
  43. auto_arrival: 0,
  44. mer_location: 0,
  45. statusBarHeight:0,
  46. mer_location: 0,
  47. store_street_theme: 1,
  48. sys_intention_agree: '',
  49. copyright_status: '',
  50. copyright_context: '',
  51. copyright_image: '',
  52. open_update_info: 0,
  53. imgColor: '',
  54. ...uni.getStorageSync('GLOBAL_DATA') || {}
  55. },
  56. onLaunch: function(option) {
  57. this.globalData.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  58. this.globalData.uid = this.$store.state.app.uid
  59. let that = this;
  60. // #ifdef MP
  61. if (HTTP_REQUEST_URL == '') {
  62. console.error(
  63. "请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
  64. );
  65. return false;
  66. }
  67. if (option.query.hasOwnProperty('scene')) {
  68. switch (option.scene) {
  69. //扫描小程序码
  70. case 1047:
  71. console.log(option, 'val')
  72. let val = that.$util.getUrlParams(decodeURIComponent(option.query.scene));
  73. that.globalData.code = val;
  74. that.globalData.uid = val
  75. break;
  76. //长按图片识别小程序码
  77. case 1048:
  78. that.globalData.code = option.query.scene;
  79. break;
  80. //手机相册选取小程序码
  81. case 1049:
  82. that.globalData.code = option.query.scene;
  83. break;
  84. //直接进入小程序
  85. case 1001:
  86. that.globalData.spid = option.query.scene;
  87. break;
  88. }
  89. }
  90. // #endif
  91. // 获取导航高度;
  92. uni.getSystemInfo({
  93. success: function(res) {
  94. that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
  95. }
  96. });
  97. // 获取配置
  98. getconfig().then(res => {
  99. uni.$emit('update', res.data)
  100. this.$store.commit('GLOBAL_DATA', res.data);
  101. this.globalData.balance_func_status = res.data.balance_func_status
  102. this.globalData.recharge_switch = res.data.recharge_switch
  103. this.globalData.routine_logo = res.data.routine_logo
  104. this.globalData.site_logo = res.data.site_logo
  105. this.globalData.login_logo = res.data.login_logo
  106. this.globalData.site_name = res.data.site_name
  107. this.globalData.store_user_min_recharge = res.data.store_user_min_recharge
  108. this.globalData.yue_pay_status = res.data.yue_pay_status
  109. this.globalData.sys_intention_agree = res.data.sys_intention_agree
  110. this.globalData.mer_intention_open = res.data.mer_intention_open
  111. this.globalData.alipay_open = res.data.alipay_open
  112. this.globalData.hide_mer_status = res.data.hide_mer_status
  113. this.globalData.mer_location = res.data.mer_location
  114. this.globalData.arrival_notice = res.data.procudt_increase_status
  115. this.globalData.auto_arrival = res.data.sys_extension_type
  116. this.globalData.member_status = res.data.member_status
  117. this.globalData.copy_command_status = res.data.copy_command_status
  118. this.globalData.is_phone_login = res.data.is_phone_login
  119. this.globalData.mer_location = res.data.mer_location
  120. this.globalData.store_street_theme = res.data.store_street_theme
  121. this.globalData.copyright_status = res.data.copyright_status
  122. this.globalData.copyright_image = res.data.copyright_image
  123. this.globalData.copyright_context = res.data.copyright_context
  124. this.globalData.open_update_info = res.data.open_update_info
  125. this.$store.commit("VIEW_COLOR", res.data.global_theme.theme)
  126. this.$store.commit("KEY_COLOR",'_' + res.data.global_theme.type)
  127. try {
  128. uni.setStorageSync('SUBSCRIBE_MESSAGE', res.data.tempid);
  129. } catch (e) {
  130. // error
  131. }
  132. // #ifdef H5
  133. this.setOpenShare(res.data);
  134. // #endif
  135. }).catch(err => {});
  136. },
  137. onShow() {
  138. let that = this
  139. // 记录H5和公众号
  140. if (this.$store.state.app.token) {
  141. // 浏览记录
  142. // #ifdef H5
  143. history({
  144. page: location.pathname + location.search,
  145. }).then(() => {});
  146. //#endif
  147. };
  148. // #ifndef H5
  149. setTimeout(()=>{
  150. if(that.globalData.copy_command_status == 1){
  151. uni.getClipboardData({
  152. success: function (res) {
  153. if(/^(\/@[1-9]{1}).*\*\//.test(res.data)){
  154. that.$store.commit("PARSE_PWD", res.data)
  155. }
  156. }
  157. })
  158. }
  159. },1500)
  160. // #endif
  161. },
  162. methods: {
  163. // 微信分享;
  164. setOpenShare: function(data) {
  165. let that = this;
  166. let href = location.href;
  167. href = href.indexOf("?") === -1 ? href + "?spid=" + this.globalData.uid : href + "&spid=" + this.globalData.uid;
  168. if (that.$wechat.isWeixin()) {
  169. let configAppMessage = {
  170. desc: data.share_info,
  171. title: data.share_title,
  172. link: href,
  173. imgUrl: data.share_pic
  174. };
  175. that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"], configAppMessage);
  176. }
  177. }
  178. },
  179. onHide: function() {
  180. //console.log('App Hide')
  181. },
  182. watch: {
  183. // 记录H5和公众号
  184. $route(n) {
  185. if (this.$store.state.app.token) {
  186. // 浏览记录
  187. history({
  188. page: location.pathname + location.search,
  189. }).then(() => {});
  190. }
  191. },
  192. }
  193. }
  194. </script>
  195. <style>
  196. @import "@/plugin/animate/animate.min.css";
  197. @import 'static/css/base.css';
  198. @import 'static/iconfont/iconfont.css';
  199. @import 'static/css/style.scss';
  200. view {
  201. box-sizing: border-box;
  202. }
  203. .bg-color-red {
  204. background-color: #e93323 !important;
  205. }
  206. .syspadding {
  207. padding-top: var(--status-bar-height);
  208. }
  209. .flex {
  210. display: flex;
  211. }
  212. .uni-scroll-view::-webkit-scrollbar {
  213. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  214. display: none
  215. }
  216. ::-webkit-scrollbar {
  217. width: 0;
  218. height: 0;
  219. color: transparent;
  220. }
  221. ::-moz-scrollbar {
  222. width: 0;
  223. height: 0;
  224. color: transparent;
  225. }
  226. .empty-txt {
  227. line-height: 100rpx;
  228. font-size: 22rpx;
  229. color: #999;
  230. text-align: center;
  231. }
  232. .product-con .conter img {
  233. display: block;
  234. }
  235. .open-location {
  236. height: 100vh;
  237. }
  238. uni-tabbar{
  239. bottom: 0;
  240. }
  241. </style>