App.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <script>//com.cityexpress1688.ptsj
  2. import {
  3. changeLanguages
  4. } from '@/pages/api/login';
  5. import api from "@/pages/api/api.js"
  6. export default {
  7. data() {
  8. return {
  9. audioObj:null
  10. }
  11. },
  12. globalData:{
  13. _i18n:{},
  14. $t:{},
  15. token:'',
  16. imViewOpen:false
  17. },
  18. onLaunch: function() {
  19. console.log('App Launch');
  20. this.globalData._i18n=this.$i18n;
  21. this.globalData.$t=str=>this.$t(str);
  22. let systemInfo = uni.getSystemInfoSync();
  23. var isAndroid = systemInfo.platform.toLowerCase() === 'android';
  24. var language = uni.getStorageSync('language');
  25. if(''==language||null==language||undefined==language){
  26. uni.setStorageSync('language',"zh-Hant");
  27. uni.setLocale('zh-Hant');
  28. if(!isAndroid){
  29. this.$i18n.locale = 'zh-Hant';
  30. }
  31. this.uploadLanguagesSet('zh-Hant');
  32. }
  33. else{
  34. uni.setLocale(language);
  35. if(!isAndroid){
  36. this.$i18n.locale = language;
  37. }
  38. this.uploadLanguagesSet(language);
  39. }
  40. uni.onPushMessage((res) => {
  41. console.log("收到推送消息:",res) //监听推送消息
  42. if(res.type=='click'){
  43. var content=res.data.content;
  44. plus.runtime.setBadgeNumber(0);
  45. if(content.indexOf("发起通话")!=-1){
  46. return
  47. }
  48. plus.runtime.setBadgeNumber(0);
  49. return
  50. }
  51. if(res.type=='receive'){
  52. var content=res.data.content;
  53. if(content.indexOf("发起通话")!=-1){
  54. plus.runtime.setBadgeNumber(0);
  55. if(this.globalData.imViewOpen==false){
  56. }
  57. return
  58. }
  59. if(content.indexOf("通话")!=-1){
  60. plus.runtime.setBadgeNumber(0);
  61. return;
  62. }
  63. plus.runtime.setBadgeNumber(0);
  64. if(content.indexOf("新订单")!=-1){
  65. this.audioObj.play();
  66. }
  67. uni.createPushMessage({
  68. content:res.data.content,
  69. success: (res) => {
  70. console.log(res);
  71. },
  72. fail(er) {
  73. }
  74. });
  75. }
  76. })
  77. this.audioObj=uni.createInnerAudioContext();
  78. this.audioObj.src='static/nyxddl.mp3';
  79. },
  80. onShow: function() {
  81. console.log('App Show')
  82. // uni.onPushMessage((res) => {
  83. // console.log(res);
  84. // })
  85. },
  86. onHide: function() {
  87. console.log('App Hide')
  88. },
  89. methods:{
  90. async uploadLanguagesSet(lang){
  91. var userId = uni.getStorageSync('userId');
  92. if(lang=='yuenan'){
  93. lang='vi';
  94. }
  95. if(lang=='zh-Hans'){
  96. lang='zh-CN';
  97. }
  98. if(lang=='zh-Hant'){
  99. lang='zh-TW';
  100. }
  101. console.log("changeLanguages");
  102. api('changeLanguages',{
  103. id:userId,
  104. lang:lang
  105. },
  106. res=>{
  107. console.log(res)
  108. },failc=>{
  109. //console.log('getadvertis----',failc)
  110. });
  111. },
  112. },
  113. }
  114. </script>
  115. <style>
  116. .container {
  117. padding: 15px;
  118. }
  119. /*
  120. button {
  121. margin-bottom: 15px;
  122. }
  123. */
  124. .ztextfontB1{
  125. font-size: 36rpx;
  126. }
  127. .ztextfontB2{
  128. font-size: 34rpx;
  129. }
  130. .ztextfontB3{
  131. font-size: 32rpx;
  132. }
  133. .ztextfontB4{
  134. font-size: 30rpx;
  135. }
  136. .ztextfontB5{
  137. font-size: 28rpx;
  138. }
  139. .ztextfontS1{
  140. font-size: 26rpx;
  141. }
  142. .ztextfontS2{
  143. font-size: 24rpx;
  144. }
  145. .ztextfontS3{
  146. font-size: 22rpx;
  147. }
  148. .textfontB1{
  149. font-size: 36rpx;
  150. }
  151. .textfontB2{
  152. font-size: 34rpx;
  153. }
  154. .textfontB3{
  155. font-size: 32rpx;
  156. }
  157. .textfontB4{
  158. font-size: 30rpx;
  159. }
  160. .textfontB5{
  161. font-size: 28rpx;
  162. }
  163. .textfontS1{
  164. font-size: 26rpx;
  165. }
  166. .textfontS2{
  167. font-size: 24rpx;
  168. }
  169. .textfontS3{
  170. font-size: 22rpx;
  171. }
  172. /*每个页面公共css */
  173. .content{
  174. display: flex;
  175. flex-direction: column;
  176. width: 94%;
  177. margin-left: 3%;
  178. background-color: white;
  179. border-radius: 16rpx;
  180. box-shadow: 0rpx 0rpx 10rpx 0rpx lightgray;
  181. }
  182. .content4{
  183. display: flex;
  184. flex-direction: column;
  185. width: 92%;
  186. margin-left: 4%;
  187. }
  188. .contentInRowL{
  189. display: flex;
  190. flex-direction: row;
  191. justify-content: flex-start;
  192. }
  193. .contentInRowC{
  194. display: flex;
  195. flex-direction: row;
  196. justify-content: center;
  197. align-items: center;
  198. }
  199. .contentInRowR{
  200. display: flex;
  201. flex-direction: row;
  202. justify-content: flex-end;
  203. }
  204. .contentInRowS{
  205. display: flex;
  206. flex-direction: row;
  207. align-items: center;
  208. justify-content: space-between;
  209. }
  210. .contentColumn{
  211. display: flex;
  212. flex-direction: column;
  213. }
  214. .contentColumnC{
  215. display: flex;
  216. flex-direction: column;
  217. align-items: center;
  218. justify-content: center;
  219. }
  220. .text1row{
  221. overflow: hidden;
  222. text-overflow: ellipsis;
  223. /* #ifndef APP-PLUS-NVUE */
  224. display: -webkit-box;
  225. -webkit-line-clamp: 1;
  226. -webkit-box-orient: vertical;
  227. /* #endif */
  228. }
  229. .text2row{
  230. overflow: hidden;
  231. text-overflow: ellipsis;
  232. /* #ifndef APP-PLUS-NVUE */
  233. display: -webkit-box;
  234. -webkit-line-clamp: 2;
  235. -webkit-box-orient: vertical;
  236. /* #endif */
  237. }
  238. </style>