Commit ec0ec7b0 by 张立顺

image 组件优化

1 parent f79467f4
/**
* 申请门店开通
*/
// import api from '~/utils/request/request'
// const serverApi = {
// productByscene:'scrm.api.busassistant.activity.productByscene'
// }
// export const productBysceneApi = (data) =>{
// return api.post(
// {
// method: serverApi.productByscene,
// ...data
// },
// true
// )
// }
......@@ -8,7 +8,16 @@ Component({
properties: {
src: {
type: String,
value: ''
value: '',
observer: function (url, o) {
if (url) {
let isWebp = url.includes('webp')
this.setData({
isWebp,
imagePath: `${IMG_URL}${url}?v=` + IMG_VERSION()
})
}
}
},
mode: {
type: String,
......@@ -24,19 +33,20 @@ Component({
* 组件的初始数据
*/
data: {
imagePath: ''
imagePath: '',
isWebp: false
},
// 组件生命周期
lifetimes: {
// 在组件实例进入页面节点树时执行
attached: function () {
let src = this.data.src
let prefix = IMG_URL
this.setData({
imagePath: `${prefix}${src}?v=` + IMG_VERSION()
})
},
// attached: function () {
// let src = this.data.src
// let prefix = IMG_URL
// this.setData({
// imagePath: `${prefix}${src}?v=` + IMG_VERSION()
// })
// },
// 在组件实例被从页面节点树移除时执行
detached: function () {}
},
......
<!--components/image/index.wxml-->
<image src="{{imagePath}}" mode="{{mode}}" webp="{{webp}}" lazy-load class="custom-class class"></image>
\ No newline at end of file
<!-- components/image/index.wxml -->
<image
src="{{imagePath}}"
mode="{{mode}}"
webp="{{webp||isWebp}}"
lazy-load
class="custom-class class" />
// pages/mineDetail/messageBox/messageBox.js
import mineApi from '~/api/mineApi/index'
// import { handleCopy } from '~/utils/utils_wx'
let drawQrcode = require('~/utils/lib/weapp-qrcode.js')
// let drawQrcode = require('~/utils/lib/weapp-qrcode.js')
import drawQrcode from '~/utils/lib/weapp-qrcode.js'
Component({
/**
* 组件的属性列表
......
// pages/tab/mine/mine.js
import { IMG_URL } from '~/utils/constantData'
// import { IMG_URL } from '~/utils/constantData'
import USERAPI from '~/api/usersApi/index'
import mineApi from '~/api/mineApi/index'
const IMAGES = Object.freeze({
icon0: `${IMG_URL}/personal/icon1.png`,
icon1: `${IMG_URL}/personal/icon2.png`,
userAvatarUrl: `${IMG_URL}/personal/userAvatarUrl.png`
icon0: `/personal/icon1.png`,
icon1: `/personal/icon2.png`,
userAvatarUrl: `/personal/userAvatarUrl.png`
})
Page({
/**
......@@ -14,12 +14,13 @@ Page({
data: {
navStyle: 'background-color: rgba(0,0,0,0);',
IMAGES,
isRead: false
isRead: false,
test: `/personal/icon2.png`
},
navGO(e) {
let { path } = e.currentTarget.dataset
console.log(path)
wx.$router.go('packagesList.customerManagement')
// console.log(path)
wx.$router.go(path)
},
logout() {
let _this = this
......@@ -56,7 +57,8 @@ Page({
.then(result => {
console.log(result)
this.setData({
isRead: result
isRead: result,
test: `/personal/icon2.png`
})
})
.catch(err => {
......
<!-- pages/tab/output/output.wxml -->
<!-- <navigation-bar navStyle="{{navStyle}}">服务商账号名称</navigation-bar>
<view class="layout">
</view> -->
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">
我的账号
<!-- <picker
range="{{merchantRange}}"
value="{{subIndex}}"
range-key="merchantName"
bindchange="changePicker"
bindtap="tapPicker"
bindcancel="tapPicker"
disabled="{{merchantRange.length < 2}}">
<view class="navigation-title">
<view class="navigation-title-text text-hide">{{merchantRange[subIndex].merchantName}}</view>
<view class="arrow {{moveArrow?'move':''}}" wx:if="{{merchantRange.length > 1}}">
<image src="{{${IMG_URL}/output/arrow.png}}" />
</view>
</view>
</picker> -->
</navigation-bar>
<navigation-bar navStyle="{{navStyle}}" bindnavbarReady="navbarReady">我的账号</navigation-bar>
<view class="layout" style="padding-top:{{tabBarStyle}}px;">
<view class="userInfoCon">
<image class="headPortrait" src="{{userInfo.userAvatarUrl||IMAGES.userAvatarUrl }}" webp>
<glsx-image class="headPortrait" src="{{userInfo.userAvatarUrl||IMAGES.userAvatarUrl }}" webp>
头像
</image>
</glsx-image>
<view class="name">{{userInfo.merchantName}}</view>
<view class="id">账号:{{userInfo.merchantId}}</view>
<view class="createTime">创建时间:{{userInfo.createdDate}}</view>
......@@ -34,14 +13,16 @@
<view class="boxItemCon">
<view class="item" data-path="packagesList.customerManagement" bind:tap="navGO">
<view class="imgcon">
<image class="img" src="{{IMAGES.icon0}}" />
<glsx-image class="img" src="{{IMAGES.icon0}}" />
</view>
<view class="name">客户管理</view>
</view>
<view class="item" data-path="packagesList.messageBox" bind:tap="navGO">
<view class="imgcon">
<view class="redPot" hidden="{{!isRead}}" />
<image class="img" src="{{IMAGES.icon1}}" />
<!-- <image class="img" src="{{IMAGES.icon1}}" /> -->
<glsx-image class="img" src="{{test}}" />
<!-- <image class="img" src="{{IMAGES.icon1}}" /> -->
</view>
<view class="name">消息盒子</view>
</view>
......
const _routeHooks = Symbol('_routeHooks')
const _query = Symbol('_query')
const _routerList = Symbol('_routerList')
import { IMG_URL, IMG_VERSION } from '~/utils/constantData'
// import { IMG_URL, IMG_VERSION } from '~/utils/constantData'
import { generateRoutList } from './wxOnAppRoute.js'
import { getNavigationBarTitleText } from '~/utils/cache/storageApi'
import { getUserInfo } from '~/utils/cache/userInfo'
......@@ -17,7 +17,7 @@ class Router {
console.log(e)
console.log(thisPage)
if (thisPage) {
thisPage.setData({ IMG_URL, img_version: IMG_VERSION() })
// thisPage.setData({ IMG_URL, img_version: IMG_VERSION() })
if (Object.keys(this[_query]).length)
thisPage.options = {
...thisPage.options,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!