Jelajahi Sumber

feat(view): 图片版本号

xiansin 3 tahun lalu
induk
melakukan
2c542b1b16

+ 1 - 0
core/apiList.js

xqd
@@ -6,6 +6,7 @@ module.exports = {
     login: '/passport/login',
     // 设置
     settingGet: '/setting/get',
+    settingConfig: '/setting/config',
 
     // 购买会员记录
     memberRecord: '/user/memberRecord',

+ 1 - 0
core/constant.js

xqd
@@ -3,4 +3,5 @@ module.exports = {
    USER_DATA: 'vuex_user_data',
    USER_SCENE: 'vuex_user_scene',
    USER_PARENT_ID: 'vuex_user_parent_id',
+   USER_CONFIG: 'vuex_user_config',
 }

+ 3 - 0
core/http.api.js

xqd xqd
@@ -7,6 +7,8 @@ const install = (Vue, vm) => {
 	const login = (data = {}) => vm.$u.post(apiList.login, data)
 	// 系统设置
 	const settingGet = (params = {}) => vm.$u.get(apiList.settingGet, params)
+	// 系统设置
+	const settingConfig = (params = {}) => vm.$u.get(apiList.settingConfig, params)
 	// 购买记录
 	const memberRecord = (params = {}) => vm.$u.get(apiList.memberRecord, params)
 	// 获取用户信息
@@ -37,6 +39,7 @@ const install = (Vue, vm) => {
 	vm.$u.api = {
 		login,
 		settingGet,
+		settingConfig,
 
 		memberRecord,
 

+ 1 - 1
core/site.js

xqd
@@ -3,6 +3,6 @@
  */
 const ENV = process.env.NODE_ENV === 'development';
 module.exports = {
-    root: 'https://sg.9026.com/',
+    root: ENV ? 'http://www.sange-bridge.me/' : 'https://sg.9026.com/',
     authKey: "!j1^z9hE4sXJdEE$#S1GLYQnWfEBakex",
 }

+ 8 - 0
pages/login/login.vue

xqd xqd
@@ -59,6 +59,7 @@
                                     _this.$u.vuex(_this.$const.USER_TOKEN,loginRes.token)
                                     _this.$u.vuex(_this.$const.USER_DATA,loginRes.user)
                                     _this.handleBind()
+                                    _this.getConfig();
                                     if(loginRes.user.nickname === '微信用户'){
                                         _this.modal.show = true;
                                     }else{
@@ -107,6 +108,13 @@
                     this.$u.vuex(this.$const.USER_SCENE, null);
                     this.$u.vuex(this.$const.USER_PARENT_ID, null);
                 })
+            },
+            getConfig(){
+                if(!this.vuex_user_config){
+                    this.$u.api.settingConfig().then(data => {
+                        this.$u.vuex(this.$const.USER_CONFIG,data)
+                    })
+                }
             }
         },
         onLoad(options) {

+ 1 - 0
pages/my/index.vue

xqd
@@ -158,6 +158,7 @@
 			sureClearCache(){
 				this.$u.vuex(this.$const.USER_TOKEN,null)
 				this.$u.vuex(this.$const.USER_DATA,null)
+				this.$u.vuex(this.$const.USER_CONFIG,null)
 				this.$jump({url:'/pages/login/login?redirect=pages/my/index',type:'redirect'})
 			},
 			handleCopy(){

+ 3 - 1
store/index.js

xqd xqd
@@ -13,7 +13,7 @@ try{
 }
 
 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
-let saveStateKeys = [constant.USER_TOKEN,constant.USER_DATA,constant.USER_SCENE,constant.USER_PARENT_ID];
+let saveStateKeys = [constant.USER_TOKEN,constant.USER_DATA,constant.USER_SCENE,constant.USER_PARENT_ID,constant.USER_CONFIG];
 
 // 保存变量到本地存储中
 const saveStorage = function(key, value){
@@ -38,6 +38,8 @@ const store = new Vuex.Store({
 		vuex_user_scene: lifeData[constant.USER_SCENE],
 		// 分享
 		vuex_user_parent_id: lifeData[constant.USER_PARENT_ID],
+		// 设置
+		vuex_user_config: lifeData[constant.USER_CONFIG],
 	},
 	mutations: {
 		$uStore(state, payload) {

+ 9 - 1
uview-ui/components/u-image/u-image.vue

xqd xqd xqd
@@ -2,7 +2,7 @@
 	<view class="u-image" @tap="onClick" :style="[wrapStyle, backgroundStyle]">
 		<image
 			v-if="!isError"
-			:src="src"
+			:src="getSrc"
 			:mode="mode"
 			@error="onErrorHandler"
 			@load="onLoadHandler"
@@ -64,6 +64,7 @@
  * @event {Function} load 图片加载成功时触发
  * @example <u-image width="100%" height="300rpx" :src="src"></u-image>
  */
+import site from '@/core/site'
 export default {
 	name: 'u-image',
 	props: {
@@ -191,6 +192,13 @@ export default {
 				style.transition = `opacity ${Number(this.durationTime) / 1000}s ease-in-out`;
 			}
 			return style;
+		},
+		getSrc(){
+			let v = this.vuex_user_config ? this.vuex_user_config.img_version : '1.0'
+			if(this.src.indexOf(site.root) === -1){
+				return  this.src;
+			}
+			return this.src +`?v=${v}`
 		}
 	},
 	methods: {