App.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <script>
  2. import StringUtil from '@/utils/StringUtil.js'
  3. var md5 = require("./utils/md5.js");
  4. export default {
  5. data() {
  6. return {
  7. param: null
  8. };
  9. },
  10. onLaunch: function(e) {
  11. // uni.setEnableDebug({
  12. // enableDebug: true
  13. // })
  14. //更新版本
  15. const updateManager = uni.getUpdateManager();
  16. updateManager.onCheckForUpdate(function (res) {
  17. // 请求完新版本信息的回调
  18. console.log("是否有新版本:",res.hasUpdate);
  19. });
  20. updateManager.onUpdateReady(function (res) {
  21. uni.showModal({
  22. title: '更新提示',
  23. content: '新版本已经准备好,是否重启应用?',
  24. success(res) {
  25. if (res.confirm) {
  26. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  27. updateManager.applyUpdate();
  28. }
  29. }
  30. });
  31. });
  32. updateManager.onUpdateFailed(function (res) {
  33. // 新的版本下载失败
  34. });
  35. this.param = e;
  36. this.execParam();
  37. this.globalData.checkIsIPhoneX();
  38. this.getOpenId();
  39. },
  40. onShow: function(e) {
  41. this.param = e;
  42. this.execParam();
  43. },
  44. onHide: function() {
  45. console.log('App Hide')
  46. },
  47. methods: {
  48. execParam() {
  49. if (this.param == null || this.param.referrerInfo == null) return;
  50. let path = this.param.path;
  51. if (StringUtil.startEqualsIgnoreCase(path, 'pages/pages/')) {
  52. path = StringUtil.replace(path, 'pages/pages/', 'pages/');
  53. if (StringUtil.eqlObjIgnoreCase(path, '/pagesM/pages/goods_des')) {
  54. let query = this.param.query;
  55. if (query == null || query.id == null || parseInt(query.id) == null || parseInt(query.id) <= 0) {
  56. path = `pages/life`;
  57. } else {
  58. path = `pages/life?type=share&id=${query.id}&path=${path}`;
  59. }
  60. }
  61. this.param.path = path;
  62. uni.reLaunch({ url: path });
  63. return;
  64. }
  65. this.param.path = path;
  66. let reqParam = this.param.referrerInfo.extraData;
  67. wx.setStorageSync('reqParam', reqParam);
  68. this.param.referrerInfo = null;
  69. },
  70. getOpenId() {
  71. var that = this;
  72. uni.login({
  73. success: res => {
  74. let params = {};
  75. params['js_code'] = res.code;
  76. params['name'] = 'community';
  77. params['app_type'] =1;
  78. // let operation = 'miniprogram/getOpenid'; //发起请求
  79. that.$http.getOpenid(params).then(res =>{
  80. //获取成功
  81. if (res.data.result_code == 1) {
  82. console.log("获取openid成功")
  83. //openid存入缓存
  84. uni.setStorageSync("openid", res.data.openid);
  85. uni.setStorageSync("appletType", res.data.appletType);
  86. that.$u.vuex('vuex_appletType',res.data.appletType)
  87. } else {
  88. that.globalData.oneFailHint(res.data.result_msg);
  89. }
  90. }
  91. );
  92. }
  93. });
  94. }
  95. },
  96. globalData: {
  97. //机构id
  98. org_id: "1",
  99. token: "j2qctr89u1xfmbjkp69hegfmqhwquycw",
  100. //对接后台的api地址
  101. apiurl: "http://192.168.1.69/app-service/app/",
  102. //远程的
  103. // apiurl: "https://community.58fo.com/api/app/",
  104. // apiurl: "http://192.168.1.19:9082/app/",
  105. // apiurl: "http://25d3f66612.zicp.vip/wuye/app-gateway/app/",
  106. // apiurl: "http://192.168.1.218:9082/app/",
  107. // apiurl: "http://192.168.1.244:9082/app/",
  108. member: null,
  109. //用户信息--后台
  110. userInfo: null,
  111. //小程序用户信息,
  112. room_list: null,
  113. //会员的房屋列表
  114. own_room_list: null,
  115. //业主身份的房子
  116. device_list: null,
  117. //会员的授权设备列表
  118. anyHousePass: false, //判断是否是第二次认证,
  119. //封装request请求
  120. /**
  121. * params 参数
  122. * operation 操作
  123. * callBack 回调函数
  124. */
  125. postRequest: function (params, operation, callBack) {
  126. let that = this; //公共参数
  127. params['org_id'] = that.org_id;
  128. params['token'] = that.token;
  129. // uni.showLoading({
  130. // mask: true
  131. // });
  132. let jsonStr = JSON.stringify(params); //数据md5签名
  133. let dataSign = md5.hex_md5(jsonStr);
  134. uni.request({
  135. url: that.apiurl + operation,
  136. method: 'POST',
  137. header: {
  138. 'content-type': 'application/json',
  139. 'data-sign': dataSign
  140. },
  141. data: jsonStr,
  142. success: function (res) {
  143. // console.info(res.header['data-sign']);
  144. // console.info(md5.hex_md5(JSON.stringify(res.data)));
  145. // uni.hideLoading();
  146. callBack(res);
  147. },
  148. fail: function (res) {
  149. uni.hideLoading();
  150. uni.showModal({
  151. title: '警告',
  152. content: '网络异常' + res.errMsg,
  153. showCancel: false,
  154. confirmText: '确认'
  155. });
  156. }
  157. });
  158. },
  159. postRequestAsync: function (params,operation) {
  160. let that = this; //公共参数
  161. params['org_id'] = that.org_id;
  162. params['token'] = that.token;
  163. let jsonStr = JSON.stringify(params); //数据md5签名
  164. let dataSign = md5.hex_md5(jsonStr);
  165. return new Promise((resolve,reject)=>{
  166. uni.request({
  167. url: that.apiurl + operation,
  168. method: 'POST',
  169. header: {
  170. 'content-type': 'application/json',
  171. 'data-sign': dataSign
  172. },
  173. data: jsonStr,
  174. success: (res)=>{
  175. resolve(res)
  176. },
  177. fail: (err)=>{
  178. uni.hideLoading();
  179. uni.showModal({
  180. title: '警告',
  181. content: '网络异常' + res.errMsg,
  182. showCancel: false,
  183. confirmText: '确认'
  184. });
  185. }
  186. })
  187. })
  188. },
  189. //上传文件
  190. uploadBase64: function (base_64_str, is_need_md5, callback) {
  191. let that = this;
  192. let params = {};
  193. params['base_64_str'] = base_64_str;
  194. params['is_need_md5'] = is_need_md5; //公共参数
  195. params['org_id'] = that.org_id;
  196. params['token'] = that.token;
  197. let operation = 'applyUser/uploadBase64File';
  198. that.postRequest(params, operation, function (res) {
  199. if (res.data.result_code == 1) {
  200. callback(res);
  201. } else {
  202. that.autoFailHint(res.data.result_msg);
  203. }
  204. });
  205. },
  206. /**
  207. * 失败提示方法方法--单按钮--手动点击关闭
  208. */
  209. oneFailHint: function (result_msg, callBack) {
  210. uni.showModal({
  211. content: result_msg,
  212. showCancel: false,
  213. confirmText: '确认',
  214. success: function (res) {
  215. if (res.confirm) {
  216. if (callBack) {
  217. callBack();
  218. }
  219. }
  220. }
  221. });
  222. },
  223. /**
  224. * 失败提示方法方法--双按钮--手动点击关闭
  225. */
  226. twoFailHint: function (result_msg, callBack) {
  227. uni.showModal({
  228. content: result_msg,
  229. confirmText: '确认',
  230. success: function (res) {
  231. if (res.confirm) {
  232. if (callBack) {
  233. callBack();
  234. }
  235. }
  236. }
  237. });
  238. },
  239. /**
  240. * 失败提示方法方法--自动关闭
  241. */
  242. autoFailHint: function (result_msg, callBack) {
  243. uni.showToast({
  244. title: result_msg,
  245. icon: 'none',
  246. duration: 2000,
  247. success: function () {
  248. if (callBack) {
  249. callBack();
  250. }
  251. }
  252. });
  253. },
  254. /**
  255. * 提示用户身份注册
  256. */
  257. footaddmore: function () {
  258. uni.showModal({
  259. title: '提示',
  260. content: ' 请先完成注册',
  261. //cancelText:'去绑定',
  262. cancelText: '取消',
  263. confirmText: '去注册',
  264. success: function (res) {
  265. if (res.confirm) {
  266. //跳转到认证页面
  267. uni.navigateTo({
  268. url:"/pages/register/register"
  269. })
  270. } else {//res.cancel
  271. //绑定界面--暂时不用
  272. // wx.navigateTo({
  273. // url: '/pages/binding/binding',
  274. // })
  275. }
  276. }
  277. });
  278. },
  279. //房屋信息完善
  280. choosePlot: function () {
  281. uni.showModal({
  282. title: '提示',
  283. content: ' 未获取到房屋信息,是否去完善',
  284. //cancelText:'去绑定',
  285. cancelText: '取消',
  286. confirmText: '去完善',
  287. success: function (res) {
  288. if (res.confirm) {
  289. console.log('用户点击了确认-去完善'); //跳转到认证页面
  290. if(!this.$isEmpty(this.globalData.totalStep)){
  291. this.globalData.totalStep=2
  292. }
  293. uni.navigateTo({
  294. url: "/pages/auth/auth"
  295. });
  296. }
  297. }
  298. });
  299. },
  300. //检测是否是iphonex以上的机型
  301. checkIsIPhoneX: function () {
  302. const self = this;
  303. uni.getSystemInfo({
  304. success: function (res) {
  305. // 根据 model 进行判断
  306. if (res.model.search('iPhone X') != -1) {
  307. //self.isIPX = true
  308. uni.setStorageSync("isIPX", true);
  309. } else {
  310. uni.setStorageSync("isIPX", false);
  311. }
  312. }
  313. });
  314. },
  315. },
  316. }
  317. </script>
  318. <style lang="scss">
  319. // 引入样式
  320. @import '@/assets/css/app.scss';
  321. @import "uview-ui/index.scss";
  322. @import "@/assets/css/main.css";
  323. @import "@/assets/css/icon.css";
  324. @import "@/assets/css/app.css";
  325. // 社区样式 begin
  326. navigator-hover {
  327. background-color: rgba(0, 0, 0, 0.1);
  328. opacity: 0.7;
  329. }
  330. input {
  331. font-family: "PingFang SC",
  332. "Hiragino Sans GB",
  333. "Heiti SC",
  334. "Microsoft YaHei",
  335. "WenQuanYi Micro Hei",
  336. sans-serif;
  337. }
  338. .fix_nav_wp-IPX {
  339. padding-bottom:68rpx;
  340. }
  341. .mt20 {
  342. margin-top: 20rpx;
  343. }
  344. .submit_btn {
  345. position: fixed;
  346. bottom: 0;
  347. left: 0;
  348. padding: 0rpx 0rpx;
  349. width: 100%;
  350. box-sizing: border-box;
  351. background: #fff;
  352. }
  353. .ar_btn {
  354. background: $base-btn-color;
  355. font-size: 32rpx;
  356. color: #fff;
  357. // border-radius: 10rpx;
  358. margin: 0rpx 0rpx;
  359. padding: 0rpx 60rpx;
  360. height: 100rpx;
  361. line-height: 100rpx;
  362. }
  363. /* 小图标 */
  364. @font-face {
  365. font-family: 'iconfont'; /* project id 930679 */
  366. src: url('//at.alicdn.com/t/font_930679_y7aw8dju2ha.eot');
  367. src: url('//at.alicdn.com/t/font_930679_y7aw8dju2ha.eot?#iefix') format('embedded-opentype'),
  368. url('//at.alicdn.com/t/font_930679_y7aw8dju2ha.woff') format('woff'),
  369. url('//at.alicdn.com/t/font_930679_y7aw8dju2ha.ttf') format('truetype'),
  370. url('//at.alicdn.com/t/font_930679_y7aw8dju2ha.svg#iconfont') format('svg');
  371. }
  372. .iconfont {
  373. font-family: "iconfont" !important;
  374. font-size: 16px;
  375. font-style: normal;
  376. -webkit-font-smoothing: antialiased;
  377. -moz-osx-font-smoothing: grayscale;
  378. }
  379. .icon-lianxigray:before { content: "\e61b"; }
  380. .icon-dispirited:before { content: "\e650"; }
  381. .icon-cha:before { content: "\e601"; }
  382. .icon-arrow-left:before { content: "\e604"; }
  383. .icon-mima:before { content: "\e603"; }
  384. .icon-xiaoxi:before { content: "\e633"; }
  385. .icon-shuoming:before { content: "\e605"; }
  386. .icon-icon-test:before { content: "\e626"; }
  387. .icon-shiming:before { content: "\e6d4"; }
  388. .icon-dingwei:before { content: "\e822"; }
  389. .icon-yemian:before { content: "\e659"; }
  390. .icon-icon-test1:before { content: "\e600"; }
  391. .icon-user:before { content: "\e602"; }
  392. .flex {
  393. display: -webkit-flex;
  394. display: flex;
  395. width: 100%;
  396. }
  397. /* 底部悬浮导航 */
  398. .fix_nav_wp {
  399. margin-top: 110rpx;
  400. height: 110rpx;
  401. position: fixed;
  402. left: 0;
  403. bottom: 0;
  404. background: #fff;
  405. z-index: 10;
  406. }
  407. .fix_nav_wp .nav_link {
  408. flex: 1;
  409. }
  410. .fix_nav_wp button {
  411. height: 110rpx;
  412. display: flex;
  413. justify-content: space-between;
  414. align-items: center;
  415. padding: 0;
  416. font-size: 22rpx;
  417. flex-direction: column;
  418. color: #999;
  419. position: relative;
  420. }
  421. .fix_nav_wp .tip_tip {
  422. position: absolute;
  423. right: 25rpx;
  424. top: 5rpx;
  425. min-width: 28rpx;
  426. line-height: 32rpx;
  427. height: 32rpx;
  428. padding: 0 8rpx;
  429. color: #fff;
  430. background: #f00;
  431. border-radius: 50em;
  432. border: 1rpx solid #fff;
  433. }
  434. .fix_nav_wp .nav_link .iconfont {
  435. height: 60rpx;
  436. font-size: 48rpx;
  437. line-height: 80rpx;
  438. color: #c4c8cc;
  439. }
  440. .fix_nav_wp .nav_link .plus_wp {
  441. width: 120rpx;
  442. height: 120rpx;
  443. margin-top: -60rpx;
  444. }
  445. .fix_nav_wp .nav_link image {
  446. width: 120rpx;
  447. height: 120rpx;
  448. }
  449. .fix_nav_wp .nav_link .txt {
  450. height: 70rpx;
  451. line-height: 60rpx;
  452. color: #444;
  453. font-size: 28rpx;
  454. }
  455. .fix_nav_wp .nav_link .iconfont {
  456. color: #444;
  457. }
  458. .fix_nav_wp .nav_link .del_ico {
  459. display: block;
  460. }
  461. .fix_nav_wp .nav_link .cur_ico {
  462. display: none;
  463. }
  464. .fix_nav_wp .nav_link.current .del_ico {
  465. display: none;
  466. }
  467. .fix_nav_wp .nav_link.current .cur_ico {
  468. display: block;
  469. color: $base-btn-color;
  470. }
  471. .fix_nav_wp .nav_link .txt_fb {
  472. line-height: 60rpx;
  473. }
  474. .fix_nav_wp .nav_link .mp_ico {
  475. font-size: 50rpx;
  476. line-height: 80rpx;
  477. }
  478. .fix_nav_wp .nav_link .xiaox_ico {
  479. font-size: 64rpx;
  480. line-height: 70rpx;
  481. }
  482. .fix_nav_wp .nav_link .my_ico {
  483. font-size: 56rpx;
  484. }
  485. .fix_nav_wp .on_cor .del_ico, .fix_nav_wp .on_cor .txt {
  486. color: $base-btn-color;
  487. }
  488. /* 清楚按钮的默认样式 */
  489. .defalut_btn {
  490. background: transparent;
  491. border: none;
  492. overflow: visible;
  493. padding-left: 0;
  494. padding-right: 0;
  495. margin-left: 0;
  496. margin-right: 0;
  497. border-radius: 0;
  498. }
  499. .defalut_btn:after {
  500. display: none;
  501. }
  502. .text-primary {
  503. color: $base-btn-color;
  504. }
  505. .submit_btn1 {
  506. margin: 60rpx 0 20rpx;
  507. padding: 0rpx 80rpx;
  508. width: 100%;
  509. box-sizing: border-box;
  510. }
  511. //社区样式 end
  512. // 商城
  513. ::-webkit-scrollbar {
  514. display: none;
  515. width: 0 !important;
  516. height: 0 !important;
  517. -webkit-appearance: none;
  518. background: transparent;
  519. }
  520. .pageBg {
  521. background: #f2f2f2;
  522. height: auto;
  523. min-height: 100vh;
  524. }
  525. .one_line_ellipsis {
  526. display: -webkit-box;
  527. overflow: hidden;
  528. -webkit-line-clamp: 1;
  529. -webkit-box-orient: vertical;
  530. }
  531. .two_line_ellipsis {
  532. display: -webkit-box;
  533. overflow: hidden;
  534. -webkit-line-clamp: 2;
  535. -webkit-box-orient: vertical;
  536. }
  537. .three_line_ellipsis {
  538. display: -webkit-box;
  539. overflow: hidden;
  540. -webkit-line-clamp: 3;
  541. -webkit-box-orient: vertical;
  542. }
  543. </style>