123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- <script>
- var user = require('./utils/user.js');
- const util = require('./utils/util.js');
- const api = require('./config/api.js');
- var app = getApp();
- export default {
- data() {
- return {};
- },
- onLaunch: function() {
- const updateManager = uni.getUpdateManager();
- uni.getUpdateManager().onUpdateReady(function() {
- updateManager.applyUpdate();
- // wx.showModal({
- // title: '更新提示',
- // content: '新版本已经准备好,是否重启应用?',
- // success: function (res) {
- // if (res.confirm) {
- // updateManager.applyUpdate();
- // }
- // }
- // });
- });
- /*网络状态
- wx.onNetworkStatusChange(function (res) {
- if (res.networkType === 'none') {
- wx.showToast({
- title: '网络已断开',
- icon: 'none'
- })
- } else if (res.networkType === "2g" || res.networkType === "3g")
- wx.showToast({
- title: '您的网络状态不佳,' + res.networkType + ',建议使用wifi',
- icon: 'none'
- });
- })*/
- // util.request(api.appTheme, {
- // }).then(res=> {
- // if (res.errno === 0) {
- // }
- // });
- //项目启动获取缓存中的皮肤
- const value = uni.getStorageSync('theme');
- console.log(value);
- if (value == 'jz') {
- this.$store.dispatch('handleActionAgree', 'jz');
- } else if (value == 'yj') {
- this.$store.dispatch('handleActionAgree', 'yj');
- } else {
- }
- const appInstance = getApp();
- console.log(appInstance);
- this.getUserOpenId();
- if (uni.getStorageSync('randomAandB') == null || uni.getStorageSync('randomAandB') == "") {
- //1是A,0是B
- let randomVar = Math.random() < 0.5 ? 0 : 1;
- // 假设这是你要存储的数据
- const timestamp = Date.now(); // 获取当前时间戳
- // 将数据和时间戳一起存储
- uni.setStorage({
- key: 'randomAandB',
- data: {
- randomAandB: randomVar,
- timestamp: timestamp
- },
- success: function() {
- console.log('数据和时间戳存储成功');
- }
- });
- } else {
- function isDataExpired(timestamp, expiryDuration) {
- const now = Date.now();
- return (now - timestamp) > expiryDuration;
- }
- let flag = false
- const expiryDuration = 3600000; // 一小时的毫秒数
- let s = uni.getStorageSync("randomAandB");
- flag = s && isDataExpired(s.timestamp, expiryDuration);
- if (flag) {
- let randomVar = Math.random() < 0.5 ? 0 : 1;
- // 假设这是你要存储的数据
- const timestamp = Date.now(); // 获取当前时间戳
- // 将数据和时间戳一起存储
- uni.setStorage({
- key: 'randomAandB',
- data: {
- randomAandB:randomVar ,
- timestamp: timestamp
- },
- success: function() {
- console.log('数据和时间戳再次存储成功');
- }
- });
- }
- }
- },
- onLoad() {
- var updateManager = uni.getUpdateManager();
- updateManager.onUpdateReady((res) => {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启小程序?',
- success: (res) => {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- }
- });
- });
- updateManager.onUpdateFailed((err) => {
- // 新的版本下载失败
- console.log('版本下载失败原因', err);
- uni.showToast({
- title: '新版本下载失败,请稍后再试',
- icon: 'none'
- });
- });
- },
- methods: {
- async getUserOpenId() {
- let that = this;
- let res = await user.userOpenId();
- console.log(res);
- let openId = res.data;
- getApp().globalData.openId = res.data;
- let uuid = uni.getStorageSync('uuid');
- if (openId == '' || openId == null || openId == undefined) {
- // 生成uuid
- if (!uuid) {
- uuid = util.creadUuid();
- uni.setStorageSync('uuid', uuid);
- }
- }
- getApp().globalData.uuid = uuid;
- // uni.setStorageSync('openId', res.data);
- },
- },
- onShow: function(options) {
- /*是否授权登录*/
- user.checkLogin()
- .then((res) => {
- this.globalData.hasLogin = true;
- if (this.globalData.checkLoginReadyCallback) {
- this.globalData.checkLoginReadyCallback();
- }
- })
- .catch(() => {
- this.globalData.hasLogin = false;
- });
- //购物车数据显示
- //user.cartcount();
- },
- globalData: {
- uuid: '',
- openId: '',
- hasLogin: false,
- //是否授权登录
- isMember: false,
- //是否是会员
- userInfo: {},
- r_userid: 0,
- //推荐人id
- iscert: false,
- //是否注册过
- mapKey: 'AEZBZ-7JYL6-N4WSL-EFMOK-SAHSO-GLFA4',
- currentLocationName: '位置获取中',
- city: '',
- rId: '',
- //引荐人ID
- shareImage: '',
- recommend: {
- //引荐人信息
- userName: '',
- avatarUrl: '',
- bCode: '',
- phone: '',
- unionId: '',
- openId: '',
- sessionKey: ''
- },
- infoGoods: {
- picUrl: '',
- name: '',
- brief: '',
- type: '0',
- id: ''
- },
- //信息收集,
- infoAddress: {
- addressId: '',
- addressDetail: ''
- },
- memberUserInfo: {
- nickName: '',
- avatarUrl: '/static/images/new/icon-user.png'
- },
- checkLoginReadyCallback: function() {
- //是否登录
- this.hasLogin = true;
- }
- }
- };
- //购物车隐藏
- // {
- // "pagePath": "pages/tabBar/cart/cart",
- // "iconPath": "static/images/cart.png",
- // "selectedIconPath": "static/images/cart@selected.png",
- // "text": "购物车"
- // },
- </script>
- <style>
- /**app.ttss**/
- .container {
- box-sizing: border-box;
- background-color: #f5f5f5;
- font-family: AlibabaPuHuiTi_2_55_Regular;
-
- }
- view,
- image,
- text,
- navigator {
- box-sizing: border-box;
- padding: 0;
- margin: 0;
- }
- page {
- color: #2a2a2a;
- /*主要颜色*/
- font-size: 28rpx;
- background: #f5f5f5;
- }
- text,
- view {
- font-family: AlibabaPuHuiTi_2_55_Regular;
- font-weight: 400;
- }
- .sub-color {
- color: #85868a;
- }
- .jz-color {
- color: #09afff;
- /*鲸致色号00AFFF*/
- }
- .van-tab>view.van-ellipsis {
- color: #888;
- }
- .van-tab--active.van-tab>view.van-ellipsis {
- color: #09afff;
- }
- van-dialog .van-button {
- color: #09afff !important;
- }
- .van-dialog__message-text {
- color: #666;
- }
- .van-button--info {
- background: #09afff !important;
- border: none !important;
- }
- .bottom-fixed-btn-wrapper {
- position: fixed;
- bottom: 146rpx;
- left: 0;
- right: 28rpx;
- left: 28rpx;
- }
- .bottom-fixed-btn-wrapper .van-button {
- height: 74rpx;
- border: none;
- }
- .common-btn-wrapper {
- margin: 0 28rpx 0;
- }
- .common-btn-wrapper .van-button {
- height: 74rpx;
- margin: 0 0 48rpx 0;
- }
- /* 云嘉样式 */
- /* .yj.container .new-item-right{
- background: #f18342;
- }
- .yj.container .add-address{
- background: #f18342;
- } */
- </style>
|