• The V-cloak command sets the style to solve the problem of flash source code displayed on the page due to slow network loading, and will be removed automatically when the compilation is finished

  • Function (x) {return x * x}, x => x * x

  • Encapsulate the message prompt box

    Vue.prototype.$showToast=function(mes){
	if(mes&&typeof mes=='string'){
		uni.showToast({
			title: mes,
			icon:'none',
			duration: 2000
		})
	}
}
this.$showToast('You don't have access.')
Copy the code
  • Pipe character filters handle floating-point decimal places

    Introduced the main. Js

    import filters from "./components/filter.js"
    Copy the code

    Root directory components creates the code

    let toFixed=(input,num)=>Number(input).toFixed(num)
    
    export default {toFixed}
    Copy the code

    In-page application

    <view class="num"V - cloak > < span > $< / span > {{tradeData. Jrje | toFixed (2)}} < / view >Copy the code

    Note: toFixed(), which can round the Number to a specified decimal Number

  • MapState () is an auxiliary function that gets values in state, so you can get multiple values directly without using a this.$state.sessionKey reference

    computed: mapState(['sessionKey'.'merchantList'.'userId'.'hadAuthorize'])
    Copy the code
  • Uni. on(eventName,callback) listens for global custom events. Events can be emitted by uni.$emit, and the callback function receives additional arguments from all incoming event-firing functions.

    uni.$on('changeMerchantIndex',()=>{
        this.setUserIdByStorage()
    })

    switchStore(index){	
        uni.$emit('changeMerchantIndex',index);
    }
Copy the code
  • Uni. setStorageSync(KEY,DATA) Stores DATA in the KEY specified in the local cache, overwriting the original content corresponding to the KEY. This is a synchronization interface
A pagesaveA() {
        uni.setStorageSync('merchantIndex',index)} B pagelet get = uni.getStorageSync('merchantIndex')
Copy the code
  • mapMutations
. mapMutations(['A') | |... mapMutations({'A': 'A' })
Copy the code
MapMutations will map this.A to this. codestore.com MIT ('A')Copy the code
  • mapState
. mapMutations(['A') | |... mapMutations({'A': 'A' })
Copy the code
MapMutations will map this.A to this.$store.$state('A')Copy the code
  • Uni. scanCode Scan the QR code
   uni.scanCode({
	success: (res) => {
	    this.codeResult = res.result
	}
})
Copy the code
  • Uni. GetLocation Gets the location
   goPositionAuthorize ({scope: authorize() {authorize() {authorize() {authorize() {authorize() {authorize() {authorize();'scope.userLocation', success: (res) => {console.log(res) uni.getLocation()}}) // Get current location uni.getLocation({success: (res) =>{// Location permission enabled, Open the map // uni.chooselocation () // get specific location information this.latitude = res.latitude // latitude this.longitude = res.longitude // precision uni.navigateTo({ url:'./scenicSpot/scenicSpot'})}, fail(e) {// Location permissions are not enabled, boot Settings uni.showModal({title:'Location not authorized',
			content: 'If you want to use Pomelo, please open the location authorization in your phone, and then reopen the mini program.',
			confirmText: 'Deauthorize',
			success(res){
			    ifUni.opensetting ({success(res) {console.log(res)}},}})}})Copy the code
  • Uni. NavigateTo () keeps the current page and jumps to a page in the app. Use uni. NavigateBack to return to the original page.
   goStatistics() {
        uni.navigateTo({
	    url:'./consumeStatistics/consumeStatistics'})},Copy the code