App.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <script>
  2. var user = require('./utils/user.js');
  3. const util = require('./utils/util.js');
  4. const api = require('./config/api.js');
  5. var app = getApp();
  6. export default {
  7. data() {
  8. return {};
  9. },
  10. onLaunch: function () {
  11. const updateManager = uni.getUpdateManager();
  12. uni.getUpdateManager().onUpdateReady(function () {
  13. updateManager.applyUpdate();
  14. // wx.showModal({
  15. // title: '更新提示',
  16. // content: '新版本已经准备好,是否重启应用?',
  17. // success: function (res) {
  18. // if (res.confirm) {
  19. // updateManager.applyUpdate();
  20. // }
  21. // }
  22. // });
  23. });
  24. /*网络状态
  25. wx.onNetworkStatusChange(function (res) {
  26. if (res.networkType === 'none') {
  27. wx.showToast({
  28. title: '网络已断开',
  29. icon: 'none'
  30. })
  31. } else if (res.networkType === "2g" || res.networkType === "3g")
  32. wx.showToast({
  33. title: '您的网络状态不佳,' + res.networkType + ',建议使用wifi',
  34. icon: 'none'
  35. });
  36. })*/
  37. // util.request(api.appTheme, {
  38. // }).then(res=> {
  39. // if (res.errno === 0) {
  40. // }
  41. // });
  42. //项目启动获取缓存中的皮肤
  43. const value = uni.getStorageSync('theme');
  44. console.log(value);
  45. if (value == 'jz') {
  46. this.$store.dispatch('handleActionAgree', 'jz');
  47. } else if (value == 'yj') {
  48. this.$store.dispatch('handleActionAgree', 'yj');
  49. } else {
  50. // this.$store.dispatch('handleActionAgree', 'yj');
  51. // this.$store.dispatch('handleActionCol', '#ff0000');
  52. // uni.setNavigationBarColor({
  53. // frontColor: '#000000',
  54. // backgroundColor:'#ff0000'
  55. // });
  56. }
  57. const appInstance = getApp();
  58. console.log(appInstance);
  59. this.getUserOpenId();
  60. },
  61. onLoad() {
  62. var updateManager = uni.getUpdateManager();
  63. updateManager.onUpdateReady((res) => {
  64. uni.showModal({
  65. title: '更新提示',
  66. content: '新版本已经准备好,是否重启小程序?',
  67. success: (res) => {
  68. if (res.confirm) {
  69. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  70. updateManager.applyUpdate();
  71. }
  72. }
  73. });
  74. });
  75. updateManager.onUpdateFailed((err) => {
  76. // 新的版本下载失败
  77. console.log('版本下载失败原因', err);
  78. uni.showToast({
  79. title: '新版本下载失败,请稍后再试',
  80. icon: 'none'
  81. });
  82. });
  83. },
  84. methods:{
  85. async getUserOpenId() {
  86. let that = this;
  87. let res = await user.userOpenId();
  88. console.log(res);
  89. let openId=res.data;
  90. getApp().globalData.openId=res.data;
  91. let uuid= uni.getStorageSync('uuid');
  92. if(openId==''||openId==null||openId==undefined){
  93. // 生成uuid
  94. if(!uuid){
  95. uuid=util.creadUuid();
  96. uni.setStorageSync('uuid',uuid);
  97. }
  98. }
  99. getApp().globalData.uuid=uuid;
  100. // uni.setStorageSync('openId', res.data);
  101. },
  102. },
  103. onShow: function (options) {
  104. /*是否授权登录*/
  105. user.checkLogin()
  106. .then((res) => {
  107. this.globalData.hasLogin = true;
  108. if (this.globalData.checkLoginReadyCallback) {
  109. this.globalData.checkLoginReadyCallback();
  110. }
  111. })
  112. .catch(() => {
  113. this.globalData.hasLogin = false;
  114. });
  115. //购物车数据显示
  116. //user.cartcount();
  117. },
  118. globalData: {
  119. uuid:'',
  120. openId:'',
  121. hasLogin: false,
  122. //是否授权登录
  123. isMember: false,
  124. //是否是会员
  125. userInfo: {},
  126. r_userid: 0,
  127. //推荐人id
  128. iscert: false,
  129. //是否注册过
  130. mapKey: 'AEZBZ-7JYL6-N4WSL-EFMOK-SAHSO-GLFA4',
  131. currentLocationName: '位置获取中',
  132. city: '',
  133. rId: '',
  134. //引荐人ID
  135. shareImage: '',
  136. recommend: {
  137. //引荐人信息
  138. userName: '',
  139. avatarUrl: '',
  140. bCode: '',
  141. phone: '',
  142. unionId: '',
  143. openId: '',
  144. sessionKey: ''
  145. },
  146. infoGoods: {
  147. picUrl: '',
  148. name: '',
  149. brief: '',
  150. type: '0',
  151. id: ''
  152. },
  153. //信息收集,
  154. infoAddress: {
  155. addressId: '',
  156. addressDetail: ''
  157. },
  158. memberUserInfo: {
  159. nickName: '',
  160. avatarUrl: '/static/images/new/icon-user.png'
  161. },
  162. checkLoginReadyCallback: function () {
  163. //是否登录
  164. this.hasLogin = true;
  165. }
  166. }
  167. };
  168. //购物车隐藏
  169. // {
  170. // "pagePath": "pages/tabBar/cart/cart",
  171. // "iconPath": "static/images/cart.png",
  172. // "selectedIconPath": "static/images/cart@selected.png",
  173. // "text": "购物车"
  174. // },
  175. </script>
  176. <style>
  177. /**app.ttss**/
  178. .container {
  179. box-sizing: border-box;
  180. background-color: #f5f5f5;
  181. font-family: PingFangSC-Light, helvetica, 'Heiti SC';
  182. }
  183. view,
  184. image,
  185. text,
  186. navigator {
  187. box-sizing: border-box;
  188. padding: 0;
  189. margin: 0;
  190. }
  191. page {
  192. color: #2a2a2a; /*主要颜色*/
  193. font-size: 28rpx;
  194. background: #f5f5f5;
  195. }
  196. text,
  197. view {
  198. font-family: PingFangSC-Light, helvetica, 'Heiti SC';
  199. /* font-weight: 500; */
  200. }
  201. .sub-color {
  202. color: #85868a;
  203. }
  204. .jz-color {
  205. color: #09afff; /*鲸致色号00AFFF*/
  206. }
  207. .van-tab > view.van-ellipsis {
  208. color: #888;
  209. }
  210. .van-tab--active.van-tab > view.van-ellipsis {
  211. color: #09afff;
  212. }
  213. van-dialog .van-button {
  214. color: #09afff !important;
  215. }
  216. .van-dialog__message-text {
  217. color: #666;
  218. }
  219. .van-button--info {
  220. background: #09afff !important;
  221. border: none !important;
  222. }
  223. .bottom-fixed-btn-wrapper {
  224. position: fixed;
  225. bottom: 146rpx;
  226. left: 0;
  227. right: 28rpx;
  228. left: 28rpx;
  229. }
  230. .bottom-fixed-btn-wrapper .van-button {
  231. height: 74rpx;
  232. border: none;
  233. }
  234. .common-btn-wrapper {
  235. margin: 0 28rpx 0;
  236. }
  237. .common-btn-wrapper .van-button {
  238. height: 74rpx;
  239. margin: 0 0 48rpx 0;
  240. }
  241. /* 云嘉样式 */
  242. /* .yj.container .new-item-right{
  243. background: #f18342;
  244. }
  245. .yj.container .add-address{
  246. background: #f18342;
  247. } */
  248. </style>