App.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <script>
  2. import Vue from 'vue'
  3. // import TIM from 'tim-wx-sdk';
  4. // import COS from 'cos-wx-sdk-v5';
  5. import {getMyStoreOrderById,finishOrder} from '@/api/storeOrder'
  6. export default {
  7. globalData: {
  8. // wsUrl: 'wss://websocket.cdwjyyh.com',
  9. wsUrl: '',
  10. appId: 'wx94951f52d3ac5e25',
  11. },
  12. onLoad: function (){
  13. },
  14. onLaunch: function() {
  15. this.checkUpdate()
  16. // 看课题目字体跟随系统变化
  17. const systemInfo = uni.getSystemInfoSync();
  18. const baseFontSize = 14; // 标准字体大小(你可以自定义)
  19. const userFontSize = systemInfo.fontSizeSetting || baseFontSize;
  20. // 计算比例
  21. const scale = userFontSize / baseFontSize;
  22. // 存储到全局变量或 Vuex
  23. uni.setStorageSync('fontScale', scale);
  24. },
  25. onShow: function (option) {
  26. console.log('App Show')
  27. console.log('对应的请求参数:', option);
  28. if (option.referrerInfo && option.referrerInfo.appId === 'wx1183b055aeec94d1') {
  29. const { extraData } = option.referrerInfo;
  30. console.log('确认收货操作状态:', extraData.status);
  31. console.log('错误信息(如果有):', extraData.errormsg);
  32. console.log('对应的请求参数:', extraData.req_extradata);
  33. // 根据状态进行不同处理
  34. switch (extraData.status) {
  35. case 'success':
  36. // 重要:通知服务器查询订单状态进行最终确认,不要仅依赖前端回调
  37. const data={
  38. transactionId:extraData.req_extradata.transaction_id
  39. }
  40. finishOrder(data).then(res => {
  41. if(res.code==200){
  42. // that.getMyStoreOrderById()
  43. uni.$emit('getOrderList',1);
  44. }else{
  45. uni.showToast({
  46. icon:'none',
  47. title: res.msg,
  48. });
  49. }
  50. });
  51. break;
  52. case 'fail':
  53. wx.showToast({
  54. title: `操作失败: ${extraData.errormsg || '未知错误'}`,
  55. icon: 'none'
  56. });
  57. break;
  58. case 'cancel':
  59. wx.showToast({
  60. title: '您取消了确认收货',
  61. icon: 'none'
  62. });
  63. break;
  64. }
  65. }
  66. uni.getSystemInfo({
  67. success: (result) => {
  68. // 获取手机系统的状态栏高度(不同手机的状态栏高度不同)
  69. // console.log('当前手机的状态栏高度',result.statusBarHeight)
  70. let statusBarHeight = result.statusBarHeight + 'px'
  71. // 获取右侧胶囊的信息 单位px
  72. //#ifndef H5 || APP-PLUS
  73. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  74. //bottom: 胶囊底部距离屏幕顶部的距离
  75. //height: 胶囊高度
  76. //left: 胶囊左侧距离屏幕左侧的距离
  77. //right: 胶囊右侧距离屏幕左侧的距离
  78. //top: 胶囊顶部距离屏幕顶部的距离
  79. //width: 胶囊宽度
  80. // console.log(menuButtonInfo.width, menuButtonInfo.height, menuButtonInfo.top)
  81. // console.log('计算胶囊右侧距离屏幕右边距离', result.screenWidth - menuButtonInfo.right)
  82. let menuWidth = menuButtonInfo.width + 'px'
  83. let menuHeight = menuButtonInfo.height + 'px'
  84. let menuBorderRadius = menuButtonInfo.height / 2 + 'px'
  85. let menuRight = result.screenWidth - menuButtonInfo.right + 'px'
  86. let menuTop = menuButtonInfo.top + 'px'
  87. let contentTop = result.statusBarHeight + 44 + 'px'
  88. let menuInfo = {
  89. statusBarHeight: statusBarHeight,//状态栏高度----用来给自定义导航条页面的顶部导航条设计padding-top使用:目的留出系统的状态栏区域
  90. menuWidth: menuWidth,//右侧的胶囊宽度--用来给自定义导航条页面的左侧胶囊设置使用
  91. menuHeight: menuHeight,//右侧的胶囊高度--用来给自定义导航条页面的左侧胶囊设置使用
  92. menuBorderRadius: menuBorderRadius,//一半的圆角--用来给自定义导航条页面的左侧胶囊设置使用
  93. menuRight: menuRight,//右侧的胶囊距离右侧屏幕距离--用来给自定义导航条页面的左侧胶囊设置使用
  94. menuTop: menuTop,//右侧的胶囊顶部距离屏幕顶部的距离--用来给自定义导航条页面的左侧胶囊设置使用
  95. contentTop: contentTop,//内容区距离页面最上方的高度--用来给自定义导航条页面的内容区定位距离使用
  96. }
  97. uni.setStorageSync('menuInfo', menuInfo)
  98. //#endif
  99. },
  100. fail: (error) => {
  101. console.log(error)
  102. }
  103. })
  104. },
  105. onHide: function() {
  106. console.log('App Hide')
  107. },
  108. methods: {
  109. checkUpdate() {
  110. const updateManager = uni.getUpdateManager();
  111. updateManager.onCheckForUpdate(function(res) {
  112. // 请求完新版本信息的回调
  113. console.log('是否有新版本:', res.hasUpdate);
  114. });
  115. updateManager.onUpdateReady(function() {
  116. uni.showModal({
  117. title: '更新提示',
  118. content: '新版本已经准备好,是否重启小程序?',
  119. confirmText: '立即重启',
  120. confirmColor: '#2179f5',
  121. showCancel: false,
  122. success(res) {
  123. if (res.confirm) {
  124. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  125. updateManager.applyUpdate();
  126. }
  127. }
  128. });
  129. });
  130. updateManager.onUpdateFailed(function() {
  131. // 新的版本下载失败
  132. uni.showModal({
  133. title: '更新提示',
  134. content: '新版本下载失败,请检查网络后重试。',
  135. showCancel: false
  136. });
  137. });
  138. },
  139. // TODO:
  140. resetLoginData() {
  141. // this.globalData.expiresIn = '';
  142. // this.globalData.sessionID = '';
  143. // this.globalData.userInfo = {
  144. // userID: '',
  145. // userSig: '',
  146. // token: '',
  147. // phone: ''
  148. // };
  149. // this.globalData.userProfile = null;
  150. // logger.log(`| app | resetLoginData | globalData: ${this.globalData}`);
  151. },
  152. onTIMError() {},
  153. onSDKReady({name}) {
  154. console.log("im注册:"+name)
  155. const isSDKReady = name === uni.$TUIKitEvent.SDK_READY ? true : false
  156. console.log("im注册:"+isSDKReady)
  157. uni.$emit('isSDKReady', {
  158. isSDKReady: true
  159. });
  160. },
  161. onNetStateChange() {},
  162. onSDKReload() {},
  163. onSdkNotReady() {},
  164. onKickedOut() {
  165. uni.showToast({
  166. title: '您被踢下线',
  167. icon: 'error'
  168. });
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="less">
  174. @import './assets/css/common.less';
  175. </style>
  176. <style lang="scss">
  177. /*每个页面公共css */
  178. @import "uview-ui/index.scss";
  179. @import './assets/iconfont/iconfont.css';
  180. @import '@/assets/css/common.scss';
  181. @import './assets/css/theme.scss';
  182. page{
  183. background-color: #f6f6f6;
  184. }
  185. ::-webkit-scrollbar{
  186. width: 0 !important;
  187. height: 0 !important;
  188. }
  189. view{
  190. box-sizing: border-box;
  191. }
  192. .ellipsis{
  193. overflow: hidden;
  194. text-overflow: ellipsis;
  195. white-space: nowrap;
  196. }
  197. .single-line-ellipsis {
  198. width: 480rpx; /* 设置固定宽度 */
  199. white-space: nowrap; /* 文本不换行 */
  200. overflow: hidden; /* 隐藏超出部分 */
  201. text-overflow: ellipsis; /* 超出部分用省略号表示 */
  202. }
  203. .single-ellipsis {
  204. width: 260rpx; /* 设置固定宽度 */
  205. white-space: nowrap; /* 文本不换行 */
  206. overflow: hidden; /* 隐藏超出部分 */
  207. text-overflow: ellipsis; /* 超出部分用省略号表示 */
  208. }
  209. .ellipsis2{
  210. overflow:hidden;
  211. text-overflow:ellipsis;
  212. display:-webkit-box;
  213. -webkit-box-orient:vertical;
  214. -webkit-line-clamp:2;
  215. }
  216. .no-data-box{
  217. height:100%;
  218. width: 100%;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. flex-direction: column;
  223. image{
  224. width: 264upx;
  225. height: 212upx;
  226. }
  227. .empty-title{
  228. margin-top: 20rpx;
  229. font-size: 28rpx;
  230. color: gray;
  231. }
  232. }
  233. .w-calc-30 {
  234. padding: 0 30rpx;
  235. width: calc(100% - 60rpx);
  236. }
  237. .hb {
  238. height: 100%;
  239. box-sizing: border-box;
  240. }
  241. .hidden {
  242. overflow: hidden;
  243. }
  244. .base-color {
  245. color: $--base-color;
  246. }
  247. .base-color-2 {
  248. color: $--base-color2;
  249. }
  250. .base-color-3 {
  251. color: $--base-color3;
  252. }
  253. .base-color-9 {
  254. color: $--base-color-9;
  255. }
  256. .base-color-8 {
  257. color: $--base-color-f8;
  258. }
  259. .base-color-6 {
  260. color: $--base-color-6;
  261. }
  262. .base-color-gray {
  263. color: $--base-color-gray;
  264. }
  265. .base-color-red{
  266. color:#ee0a25;
  267. }
  268. .base-color-dark {
  269. color: $--base-color-dark;
  270. }
  271. .base-color-dark2 {
  272. color: $--base-color-dark2;
  273. }
  274. .base-price {
  275. color: $--base-color-price;
  276. }
  277. .base-success {
  278. color: $--base-color-success;
  279. }
  280. .base-bg {
  281. background: $--base-bg;
  282. }
  283. .base-bg-2 {
  284. background: $--base-bg2;
  285. }
  286. .base-bg-red{
  287. background: #ee0a25;
  288. }
  289. .base-bg-f{
  290. background-color:#fff;
  291. }
  292. .base-bg-f8{
  293. background-color: $--base-color-f8;
  294. }
  295. .base-bg-f5{
  296. background-color: $--base-color-f5;
  297. }
  298. .base-bg-9{
  299. background-color: $--base-color-9;
  300. }
  301. .base-bg-blue{
  302. background:$--base-bg-blue;
  303. }
  304. .base-bg-sure{
  305. background:$--base-sure-bg;
  306. }
  307. .base-bg-orange{
  308. background:$--base-bg-orange;
  309. }
  310. .base-bg-false{
  311. background:$--base-false-bg;
  312. }
  313. .bor-blue{
  314. border: 2rpx solid $--base-bor-blue;
  315. }
  316. .bor-red{
  317. border: 2rpx solid $--base-bor-red;
  318. }
  319. .colorf {
  320. color: #fff;
  321. }
  322. .bgf {
  323. background: #fff;
  324. }
  325. .fixed {
  326. position: fixed;
  327. }
  328. .absolute {
  329. position: absolute;
  330. }
  331. .relative {
  332. position: relative;
  333. }
  334. .w100 {
  335. width: 100%;
  336. }
  337. .h100 {
  338. height: 100%;
  339. }
  340. .card {
  341. background: #fff;
  342. border-radius: 15rpx;
  343. }
  344. .cover-height {
  345. height: 100%;
  346. display: flex;
  347. flex-direction: column;
  348. box-sizing: border-box;
  349. }
  350. .row {
  351. display: flex;
  352. flex-direction: row;
  353. }
  354. .column {
  355. display: flex;
  356. flex-direction: column;
  357. }
  358. .justify-start {
  359. display: flex;
  360. justify-content: flex-start;
  361. }
  362. .justify-center {
  363. display: flex;
  364. justify-content: center;
  365. }
  366. .justify-end {
  367. display: flex;
  368. justify-content: flex-end;
  369. }
  370. .justify-around {
  371. display: flex;
  372. justify-content: space-around;
  373. }
  374. .justify-evenly {
  375. display: flex;
  376. justify-content: space-evenly;
  377. }
  378. .justify-between {
  379. display: flex;
  380. justify-content: space-between;
  381. }
  382. .align-start {
  383. display: flex;
  384. align-items: flex-start;
  385. }
  386. .align-center {
  387. display: flex;
  388. align-items: center;
  389. }
  390. .align-end {
  391. display: flex;
  392. align-items: flex-end;
  393. }
  394. .center {
  395. display: flex;
  396. justify-content: center;
  397. align-items: center;
  398. }
  399. .centerV {
  400. display: flex;
  401. justify-content: center;
  402. align-items: center;
  403. flex-direction: column;
  404. }
  405. .wrap {
  406. flex-wrap: wrap;
  407. }
  408. .flex-1 {
  409. flex: 1;
  410. }
  411. .ellipsis {
  412. overflow: hidden;
  413. text-overflow: ellipsis;
  414. display: -webkit-box;
  415. -webkit-box-orient: vertical;
  416. box-sizing: border-box;
  417. width: 100%;
  418. -webkit-line-clamp: 1;
  419. }
  420. .lines-2 {
  421. -webkit-line-clamp: 2 !important;
  422. }
  423. .lines-3 {
  424. -webkit-line-clamp: 3 !important;
  425. }
  426. .bold {
  427. font-weight: bold;
  428. }
  429. .line-through {
  430. text-decoration: line-through;
  431. }
  432. .nowrap {
  433. white-space: nowrap;
  434. }
  435. .scrollx {
  436. overflow-x: scroll;
  437. }
  438. .scrolly {
  439. overflow-y: scroll;
  440. }
  441. .cvauto {
  442. content-visibility: auto;
  443. }
  444. </style>
  445. <style>
  446. /*每个页面公共css */
  447. /* 解决小程序和app滚动条的问题 */
  448. /* #ifdef MP-WEIXIN || APP-PLUS */
  449. :deep(::-webkit-scrollbar ){
  450. display: none !important;
  451. width: 0 !important;
  452. height: 0 !important;
  453. -webkit-appearance: none;
  454. background: transparent;
  455. color: transparent;
  456. }
  457. /* #endif */
  458. /* 解决H5 的问题 */
  459. /* #ifdef H5 */
  460. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  461. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  462. display: none;
  463. width: 0 !important;
  464. height: 0 !important;
  465. -webkit-appearance: none;
  466. background: transparent;
  467. color: transparent;
  468. }
  469. /* #endif */
  470. </style>