App.vue 14 KB

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