App.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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: 'wx3fb7ca188c55e2e8',
  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. checkUpdates(){
  110. const updateManager = uni.getUpdateManager();
  111. uni.showModal({
  112. title: '更新提示',
  113. content: '新版本已经准备好,是否重启小程序?',
  114. confirmText: '立即重启',
  115. confirmColor: '#2179f5',
  116. showCancel: false,
  117. success(res) {
  118. if (res.confirm) {
  119. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  120. updateManager.applyUpdate();
  121. }
  122. }
  123. });
  124. updateManager.onUpdateFailed(function() {
  125. // 新的版本下载失败
  126. uni.showModal({
  127. title: '更新提示',
  128. content: '新版本下载失败,请检查网络后重试。',
  129. showCancel: false
  130. });
  131. });
  132. },
  133. checkUpdate() {
  134. const updateManager = uni.getUpdateManager();
  135. updateManager.onCheckForUpdate(function(res) {
  136. // 请求完新版本信息的回调
  137. console.log('是否有新版本:', res.hasUpdate);
  138. });
  139. updateManager.onUpdateReady(function() {
  140. uni.removeStorageSync('userInfo')
  141. uni.removeStorageSync('TOKEN_WEXIN')
  142. uni.removeStorageSync('userinfos')
  143. uni.showModal({
  144. title: '更新提示',
  145. content: '新版本已经准备好,是否重启小程序?',
  146. confirmText: '立即重启',
  147. confirmColor: '#2179f5',
  148. showCancel: false,
  149. success(res) {
  150. if (res.confirm) {
  151. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  152. updateManager.applyUpdate();
  153. }
  154. }
  155. });
  156. });
  157. updateManager.onUpdateFailed(function() {
  158. // 新的版本下载失败
  159. uni.showModal({
  160. title: '更新提示',
  161. content: '新版本下载失败,请检查网络后重试。',
  162. showCancel: false
  163. });
  164. });
  165. },
  166. // TODO:
  167. resetLoginData() {
  168. // this.globalData.expiresIn = '';
  169. // this.globalData.sessionID = '';
  170. // this.globalData.userInfo = {
  171. // userID: '',
  172. // userSig: '',
  173. // token: '',
  174. // phone: ''
  175. // };
  176. // this.globalData.userProfile = null;
  177. // logger.log(`| app | resetLoginData | globalData: ${this.globalData}`);
  178. },
  179. onTIMError() {},
  180. onSDKReady({name}) {
  181. console.log("im注册:"+name)
  182. const isSDKReady = name === uni.$TUIKitEvent.SDK_READY ? true : false
  183. console.log("im注册:"+isSDKReady)
  184. uni.$emit('isSDKReady', {
  185. isSDKReady: true
  186. });
  187. },
  188. onNetStateChange() {},
  189. onSDKReload() {},
  190. onSdkNotReady() {},
  191. onKickedOut() {
  192. uni.showToast({
  193. title: '您被踢下线',
  194. icon: 'error'
  195. });
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="less">
  201. @import './assets/css/common.less';
  202. </style>
  203. <style lang="scss">
  204. /*每个页面公共css */
  205. @import "uview-ui/index.scss";
  206. @import './assets/iconfont/iconfont.css';
  207. @import '@/assets/css/common.scss';
  208. @import './assets/css/theme.scss';
  209. page{
  210. background-color: #f6f6f6;
  211. }
  212. ::-webkit-scrollbar{
  213. width: 0 !important;
  214. height: 0 !important;
  215. }
  216. view{
  217. box-sizing: border-box;
  218. }
  219. .ellipsis{
  220. overflow: hidden;
  221. text-overflow: ellipsis;
  222. white-space: nowrap;
  223. }
  224. .single-line-ellipsis {
  225. width: 480rpx; /* 设置固定宽度 */
  226. white-space: nowrap; /* 文本不换行 */
  227. overflow: hidden; /* 隐藏超出部分 */
  228. text-overflow: ellipsis; /* 超出部分用省略号表示 */
  229. }
  230. .single-ellipsis {
  231. width: 260rpx; /* 设置固定宽度 */
  232. white-space: nowrap; /* 文本不换行 */
  233. overflow: hidden; /* 隐藏超出部分 */
  234. text-overflow: ellipsis; /* 超出部分用省略号表示 */
  235. }
  236. .ellipsis2{
  237. overflow:hidden;
  238. text-overflow:ellipsis;
  239. display:-webkit-box;
  240. -webkit-box-orient:vertical;
  241. -webkit-line-clamp:2;
  242. }
  243. .no-data-box{
  244. height:100%;
  245. width: 100%;
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. flex-direction: column;
  250. image{
  251. width: 264upx;
  252. height: 212upx;
  253. }
  254. .empty-title{
  255. margin-top: 20rpx;
  256. font-size: 28rpx;
  257. color: gray;
  258. }
  259. }
  260. .w-calc-30 {
  261. padding: 0 30rpx;
  262. width: calc(100% - 60rpx);
  263. }
  264. .hb {
  265. height: 100%;
  266. box-sizing: border-box;
  267. }
  268. .hidden {
  269. overflow: hidden;
  270. }
  271. .base-color {
  272. color: $--base-color;
  273. }
  274. .base-color-2 {
  275. color: $--base-color2;
  276. }
  277. .base-color-3 {
  278. color: $--base-color3;
  279. }
  280. .base-color-9 {
  281. color: $--base-color-9;
  282. }
  283. .base-color-8 {
  284. color: $--base-color-f8;
  285. }
  286. .base-color-6 {
  287. color: $--base-color-6;
  288. }
  289. .base-color-gray {
  290. color: $--base-color-gray;
  291. }
  292. .base-color-red{
  293. color:#ee0a25;
  294. }
  295. .base-color-dark {
  296. color: $--base-color-dark;
  297. }
  298. .base-color-dark2 {
  299. color: $--base-color-dark2;
  300. }
  301. .base-price {
  302. color: $--base-color-price;
  303. }
  304. .base-success {
  305. color: $--base-color-success;
  306. }
  307. .base-bg {
  308. background: $--base-bg;
  309. }
  310. .base-bg-2 {
  311. background: $--base-bg2;
  312. }
  313. .base-bg-red{
  314. background: #ee0a25;
  315. }
  316. .base-bg-f{
  317. background-color:#fff;
  318. }
  319. .base-bg-f8{
  320. background-color: $--base-color-f8;
  321. }
  322. .base-bg-f5{
  323. background-color: $--base-color-f5;
  324. }
  325. .base-bg-9{
  326. background-color: $--base-color-9;
  327. }
  328. .base-bg-blue{
  329. background:$--base-bg-blue;
  330. }
  331. .base-bg-sure{
  332. background:$--base-sure-bg;
  333. }
  334. .base-bg-orange{
  335. background:$--base-bg-orange;
  336. }
  337. .base-bg-false{
  338. background:$--base-false-bg;
  339. }
  340. .bor-blue{
  341. border: 2rpx solid $--base-bor-blue;
  342. }
  343. .bor-red{
  344. border: 2rpx solid $--base-bor-red;
  345. }
  346. .colorf {
  347. color: #fff;
  348. }
  349. .bgf {
  350. background: #fff;
  351. }
  352. .fixed {
  353. position: fixed;
  354. }
  355. .absolute {
  356. position: absolute;
  357. }
  358. .relative {
  359. position: relative;
  360. }
  361. .w100 {
  362. width: 100%;
  363. }
  364. .h100 {
  365. height: 100%;
  366. }
  367. .card {
  368. background: #fff;
  369. border-radius: 15rpx;
  370. }
  371. .cover-height {
  372. height: 100%;
  373. display: flex;
  374. flex-direction: column;
  375. box-sizing: border-box;
  376. }
  377. .row {
  378. display: flex;
  379. flex-direction: row;
  380. }
  381. .column {
  382. display: flex;
  383. flex-direction: column;
  384. }
  385. .justify-start {
  386. display: flex;
  387. justify-content: flex-start;
  388. }
  389. .justify-center {
  390. display: flex;
  391. justify-content: center;
  392. }
  393. .justify-end {
  394. display: flex;
  395. justify-content: flex-end;
  396. }
  397. .justify-around {
  398. display: flex;
  399. justify-content: space-around;
  400. }
  401. .justify-evenly {
  402. display: flex;
  403. justify-content: space-evenly;
  404. }
  405. .justify-between {
  406. display: flex;
  407. justify-content: space-between;
  408. }
  409. .align-start {
  410. display: flex;
  411. align-items: flex-start;
  412. }
  413. .align-center {
  414. display: flex;
  415. align-items: center;
  416. }
  417. .align-end {
  418. display: flex;
  419. align-items: flex-end;
  420. }
  421. .center {
  422. display: flex;
  423. justify-content: center;
  424. align-items: center;
  425. }
  426. .centerV {
  427. display: flex;
  428. justify-content: center;
  429. align-items: center;
  430. flex-direction: column;
  431. }
  432. .wrap {
  433. flex-wrap: wrap;
  434. }
  435. .flex-1 {
  436. flex: 1;
  437. }
  438. .ellipsis {
  439. overflow: hidden;
  440. text-overflow: ellipsis;
  441. display: -webkit-box;
  442. -webkit-box-orient: vertical;
  443. box-sizing: border-box;
  444. width: 100%;
  445. -webkit-line-clamp: 1;
  446. }
  447. .lines-2 {
  448. -webkit-line-clamp: 2 !important;
  449. }
  450. .lines-3 {
  451. -webkit-line-clamp: 3 !important;
  452. }
  453. .bold {
  454. font-weight: bold;
  455. }
  456. .line-through {
  457. text-decoration: line-through;
  458. }
  459. .nowrap {
  460. white-space: nowrap;
  461. }
  462. .scrollx {
  463. overflow-x: scroll;
  464. }
  465. .scrolly {
  466. overflow-y: scroll;
  467. }
  468. .cvauto {
  469. content-visibility: auto;
  470. }
  471. </style>
  472. <style>
  473. /*每个页面公共css */
  474. /* 解决小程序和app滚动条的问题 */
  475. /* #ifdef MP-WEIXIN || APP-PLUS */
  476. :deep(::-webkit-scrollbar ){
  477. display: none !important;
  478. width: 0 !important;
  479. height: 0 !important;
  480. -webkit-appearance: none;
  481. background: transparent;
  482. color: transparent;
  483. }
  484. /* #endif */
  485. /* 解决H5 的问题 */
  486. /* #ifdef H5 */
  487. uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
  488. /* 隐藏滚动条,但依旧具备可以滚动的功能 */
  489. display: none;
  490. width: 0 !important;
  491. height: 0 !important;
  492. -webkit-appearance: none;
  493. background: transparent;
  494. color: transparent;
  495. }
  496. /* #endif */
  497. </style>