App.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <script>
  2. import api from "./library/index.js"
  3. import http from "./library/http.js"
  4. export default {
  5. data() {
  6. return {
  7. state: 0
  8. };
  9. },
  10. methods: {
  11. check_update() {
  12. /** 检测升级 */
  13. // #ifdef APP-PLUS
  14. let _this = this;
  15. plus.runtime.getProperty(plus.runtime.appid, function(info) {
  16. api.update({
  17. version: info.version,
  18. osname: plus.os.name
  19. }).then(res => {
  20. console.log(res);
  21. if (res.data.status == 1) {
  22. uni.navigateTo({
  23. url: '/pages/index/upApp'
  24. })
  25. // uni.showModal({ //提醒用户更新
  26. // title: "更新提示",
  27. // content: res.data.content,
  28. // cancelText: '下次再说',
  29. // confirmText: '立即更新',
  30. // success: (r) => {
  31. // if (r.confirm) {
  32. // plus.runtime.openURL(res.data.downurl);
  33. // }
  34. // }
  35. // })
  36. }
  37. })
  38. });
  39. // #endif
  40. },
  41. tochat(message) {
  42. if (uni.getStorageSync('ispush') != false) {
  43. if (message.id > 0) {
  44. var url = "pages/friend/chat?id=" + message.id;
  45. if (message.type == 'group') url = "pages/group/chat?id=" + message.id;
  46. uni.navigateTo({
  47. url: url
  48. })
  49. // console.log(url)
  50. } else {
  51. uni.navigateTo({
  52. url: 'pages/index/index',
  53. success: () => {
  54. uni.setStorageSync('ispush', false)
  55. }
  56. })
  57. }
  58. }
  59. },
  60. handlePush(message, type) {
  61. try {
  62. message = JSON.parse(message);
  63. } catch (e) {
  64. //TODO handle the exception
  65. }
  66. if (message.payload != undefined) {
  67. message = message.payload;
  68. try {
  69. message = JSON.parse(message);
  70. } catch (e) {
  71. //TODO handle the exception
  72. }
  73. }
  74. uni.setStorageSync('ispush', true);
  75. uni.setStorageSync('pushmessage', message)
  76. if (type == 'click') {
  77. var that = this;
  78. uni.$emit('toChat', message);
  79. } else {
  80. if(state==0){
  81. console.log(message);
  82. plus.push.createMessage(message.content, JSON.stringify(message), {
  83. cover: true,
  84. title: message.title
  85. });
  86. }
  87. }
  88. },
  89. bindcid() {
  90. var user = uni.getStorageSync('userInfo');
  91. if (user.id > 0) {
  92. var clientid= plus.push.getClientInfo().clientid;
  93. http.setWait(false).get('index.php?act=bindcid',{cid:clientid,userid:user.id,osname:plus.os.name}).then(res=>{
  94. })
  95. }
  96. },
  97. client_change(isonline) {
  98. this.state = isonline;
  99. // #ifdef APP-PLUS
  100. if(isonline==1) plus.push.clear();
  101. var clientid= plus.push.getClientInfo().clientid;
  102. http.setWait(false).get('index.php?act=client_change',{cid:clientid,isonline:isonline}).then(res=>{
  103. });
  104. // #endif
  105. }
  106. },
  107. onLaunch() {
  108. this.$action.init();
  109. // #ifdef APP-PLUS
  110. /** 锁定屏幕方向 */
  111. plus.screen.lockOrientation('portrait-primary');
  112. var that = this;
  113. // this.bindcid();
  114. setTimeout(function() {
  115. that.check_update();
  116. }, 1000)
  117. // var that = this;
  118. //监听push推送通知
  119. plus.push.addEventListener('receive', function(message) {
  120. // console.log('receive')
  121. that.handlePush(message, 'receive');
  122. });
  123. //监听点击通知栏
  124. plus.push.addEventListener('click', function(message) {
  125. that.handlePush(message, 'click');
  126. });
  127. // #endif
  128. },
  129. onHide() {
  130. this.client_change(0);
  131. // var message={title:'标题测试',content:'内容2222',id:86668,type:'friend'}
  132. // plus.push.createMessage(message.content, JSON.stringify(message), {
  133. // cover: true,
  134. // title: message.title
  135. // });
  136. // console.log(message);
  137. // uni.createPushMessage({
  138. // title: '测试',
  139. // content: '测试内容',
  140. // complete(e) {
  141. // console.log(e,'err')
  142. // }
  143. // })
  144. },
  145. onShow() {
  146. this.client_change(1);
  147. },
  148. }
  149. </script>
  150. <style lang="scss">
  151. // 图标字体
  152. @font-face {
  153. font-family: fonticon;
  154. src: url('~@/static/iconfont.ttf');
  155. }
  156. .emoji {
  157. font-family: fonticon;
  158. font-size: 44upx;
  159. }
  160. // 所有页面都应该使用该类类初始化页面背景、大小和盒子模型
  161. .page {
  162. -webkit-touch-callout: none;
  163. /*系统默认菜单被禁用*/
  164. -webkit-user-select: none;
  165. /*webkit浏览器*/
  166. -khtml-user-select: none;
  167. /*早起浏览器*/
  168. -moz-user-select: none;
  169. /*火狐浏览器*/
  170. -ms-user-select: none;
  171. /*IE浏览器*/
  172. user-select: none;
  173. /*用户是否能够选中文本*/
  174. background-color: #FFFFFF;
  175. width: 100vw;
  176. min-height: 100vh;
  177. box-sizing: border-box;
  178. &--divider::before {
  179. z-index: 100;
  180. position: fixed;
  181. top: 0;
  182. left: 0;
  183. width: 100vw;
  184. height: 1upx;
  185. background-color: #ddd;
  186. display: block;
  187. content: '';
  188. transform: scaleY(0.5);
  189. }
  190. }
  191. // 参考 https://uniapp.dcloud.io/component/navigator?id=navigator
  192. // 去掉 navigator 组件的默认的点击态效果
  193. .navigator-hover {
  194. position: relative;
  195. background-color: transparent;
  196. opacity: 1;
  197. }
  198. // 简单容器样式
  199. .widget {
  200. background-color: transparent;
  201. padding: 0px 0px;
  202. &+& {
  203. padding-top: 0;
  204. }
  205. &-inner {
  206. border-radius: $uni-border-radius-base;
  207. background-color: $uni-text-color-inverse;
  208. }
  209. &-inner+&-inner {
  210. margin-top: $uni-spacing-col-base;
  211. }
  212. }
  213. // 基本按钮样式
  214. .btn {
  215. padding: 28upx;
  216. border-radius: $uni-border-radius-base;
  217. text-align: center;
  218. font-size: 30upx;
  219. background-color: $uni-text-color-inverse;
  220. color: $uni-text-color;
  221. border: 1upx solid rgba(#000000, .1);
  222. &-round {
  223. border-radius: 100upx;
  224. }
  225. &-primary {
  226. background-color: $uni-color-primary;
  227. color: $uni-text-color-inverse;
  228. }
  229. &-success {
  230. background-color: $uni-color-success;
  231. color: $uni-text-color-inverse;
  232. }
  233. &-warning {
  234. background-color: $uni-color-warning;
  235. color: $uni-text-color-inverse;
  236. }
  237. &-error {
  238. background-color: $uni-color-error;
  239. color: $uni-text-color-inverse;
  240. }
  241. }
  242. .cell-wrapper {
  243. position: relative;
  244. margin-top: $uni-spacing-col-base;
  245. background-color: #fff;
  246. .cell-hd::before,
  247. &::before,
  248. &::after {
  249. display: block;
  250. content: '';
  251. position: absolute;
  252. right: 0;
  253. height: 1upx;
  254. transform: scaleY(0.5);
  255. background-color: #ddd;
  256. }
  257. &::before {
  258. left: 0;
  259. top: 0;
  260. }
  261. &:after {
  262. left: 0;
  263. bottom: 0;
  264. }
  265. }
  266. .cell {
  267. position: relative;
  268. padding: 0 $uni-spacing-row-lg;
  269. line-height: 106upx;
  270. display: flex;
  271. justify-content: space-between;
  272. align-items: center;
  273. flex-direction: row;
  274. box-sizing: border-box;
  275. &:first-child &-hd::before {
  276. display: none;
  277. }
  278. &-hd {
  279. font-size: 30upx;
  280. &::before {
  281. top: 0;
  282. left: $uni-spacing-row-lg;
  283. }
  284. }
  285. &-hb {
  286. font-size: 30upx;
  287. color: #777;
  288. }
  289. &.arrow {
  290. padding-right: $uni-spacing-row-lg + 25upx;
  291. }
  292. &.arrow::before,
  293. &.arrow::after {
  294. position: absolute;
  295. transform: rotate(45deg);
  296. width: 20upx;
  297. height: 20upx;
  298. content: '';
  299. display: block;
  300. top: 50%;
  301. margin-top: -11upx;
  302. }
  303. &.arrow::before {
  304. background-color: #777;
  305. right: $uni-spacing-row-lg;
  306. }
  307. &.arrow::after {
  308. background-color: #fff;
  309. right: $uni-spacing-row-lg + 4upx;
  310. }
  311. }
  312. @font-face {
  313. font-family: "HMfont-home";
  314. src: url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAn8AAsAAAAAE1wAAAmvAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCFDAqWYJI9ATYCJANACyIABCAFhFUHgV8bThBRlFFWNdkXBXbDsSFQq221McNWrxUbYqGhiTju98MTeXqNh/9fo90388cEMe0bwSOJRIjavZIgESqnE5J5JqQVDZH/XdNfoHSAjqKqRsA+Tf/Ruya33E/bkdHsJtycY2XWAGbM5oenzf173A3lHrEilsmMbu74Y5VmYtxpgza9DMxkWL0gfjGbGRE54AL2f2ut3h2u8Q7RaZRCjDPLIv8cfAUR30MtEUWbSReVJkk0RB4lWWkNg7WVA1sBKmIUdr0uzibQOmxA4vrWwQXkJUweKHPfdwXkA+FSik2o1aVizyTegEKdvWINwGv59bEGY9GeTJFjW95pswIrzz3LYi//0O4JEaDrY3DZjxwXgUR8V3IfIeXARaloVRXT3mK/tsi3LubcJfese8l96Xbd1l1ve2z7eJp5lv3zB7URSdJNYd3Dfm7UUxxkGu0sLFcbVEa5pP3D6/QmokQw3OGzfJp/2kBkLJYQDYuziJbFJUSweIkoWXQRNYuEGFi0BLzFOhAjS4+InKUPRGI5I2a+kg7VSWUGoXoos2BNmGIWexwFroD8IUD6C1A9lYp8F3ClwsFgcgPdNpN08v1czkEOJ4aeieaC3QyVfb9PX2kbn9/0CwTeNAm79H1Kc2x3i9C7LcEZtMSLfE6T4aM+YWOm06dZ5cm9I+xoYw+rqGlScKKlHytu9h6Dw0E5nXK7nbTZknT1jFldR9cuzNMz9Srf7FydqpYW5mRr6Dq1OC9HqzYzoiw1cjohV2tX1Ji1K9bSdVkEbaxS1xQwpmpVpUFheyyzPyGdbXKHexkByib+vtgeK1X75xKqWl+grUNIbRZDXT31tBMiPZAyF0KmniCQhSgACkh5+gIxtvTS/si+VjbAuY6SMdCzbqInzwkjk5ENzMCkNv+ghQQ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DKeq/KV5AR89+zc6OGjKSKtxUqR4NtF47VuMZemcTBDQxGqzqqrXIMCnm2xkXq1QJIIkO8EpmROcOkIyevYmhUqurWBmgCe4U5WJFHiiLKqKKOJtrooo8hxphihl6g5bGv3MAXkfBvPaFbVq6ga4Uq+wWdEfo6NVTmr1oVkYoye2NvfCWLmYQx0sjozFSxszhZ4Ctjb7QtavLQDNa0L5HRZQYJYxrNLbJR4QhZvOV46Fm/lqB428nsrJSx/OwbEgYA') format('woff2');
  315. }
  316. .n-icon {
  317. font-family: "HMfont-home" !important;
  318. }
  319. .n-icon-face:before {
  320. content: "\e797";
  321. }
  322. .n-icon-keyboard:before {
  323. content: "\e7b2";
  324. }
  325. .n-icon-voice:before {
  326. content: "\e805";
  327. }
  328. .n-icon-image:before {
  329. content: "\e639";
  330. }
  331. .n-icon-paizhao:before {
  332. content: "\e63e";
  333. }
  334. .n-icon-thunder:before {
  335. content: "\e63a";
  336. }
  337. </style>