App.vue 19 KB

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