preface

Due to their own bookkeeping needs, after trying to use the market bookkeeping software, found that most of the following problems

  • There are many advertisements, mainly divided into information flow advertising and financial advertising
  • Page is too carbuncle swelling, use experience is not good
  • Some advanced functions, such as data export, cost a fee

Therefore, I came up with the idea of making a bookkeeping software by myself. This idea was landed around May 2020, so far it has been nearly a year. In line with the idea of OpenSource, all OpenSource, also want to borrow the opportunity to write a blog to get some Star❤

The test environment

  • PC: PC for account simplification

Formal environment:

  • Small program: wechat search
  • PC: PC for account simplification

Github open Source:

  • Java back end: Simplified account back end
  • PC: PC for account simplification
  • Small program: Simple account UNIAPP

The next function to be done (priority to bottom)

  • Support multiple accounts, can be customized maintenance
  • Support setup budget (year/year budget)
  • Support multi-account write-off
  • Support Excel export (customizable year or month)
  • Support multi-person bookkeeping and family bookkeeping

Bugs to be solved

  • If the user has not logged in to the applet, the applet scan code authorization will prompt that the Token cannot be empty (provider:Meow has a little boob)

If you have any other thoughts or questions, please leave me a comment, or post Pr&Issue tips on Github: If you want your writing to be used, please join me in maintaining the brief

Past the link

  • Brief account main function introduction
  • Brief introduction and deployment of the accounting backend environment
  • Brief introduction and deployment of account front end environment

One, problem recurrence

First of all, thanks to meow for the little Mimi feedback

After testing, the following steps can be reproduced

  1. Simple account small program exit
  2. Open the PC terminal
  3. Sweep WeChat yards
  4. Prompt authorization
  5. After you click Authorization, a message is displayed indicating that the Token cannot be empty

Second, problem analysis and positioning

Since can reproduce the problem, then solve the problem is not what difficult!

1. First take a look at the normal login process (some details simplified)

2. Problem location

The system displays a message indicating that the token cannot be empty in the following two situations

  • Scan for authorization before the user has logged in
  • When the network environment is poor, the user initiates authorization before obtaining the token

To sum up, the correct authorization flow chart is shown below

Third, solve problems

Tips: The following code can be found on Github, please check the wechat mini program for the code

1. Make sure the page onLoad is executed after onLaunch

Mount $Store in main.js

Vue.prototype.$onLaunched = new Promise(resolve= > {
    Vue.prototype.$isResolve = resolve
})
Vue.prototype.$store = store	// Mount the Vue instance
Copy the code

2. Attempts to obtain the token during startup

If there is an openId, the system requests the token for permission. If there is no direct permission

onLaunch: function() {
	console.log('App Launch');
	let userInfo = uni.getStorageSync("userInfo");
	if(userInfo.openId) {
		// If user information is stored locally
		this.$u.api.wxLogin({
			openId : userInfo.openId,
			username: userInfo.name,
			nickname: userInfo.nike,
			sex: userInfo.sex,
			avatar: userInfo.avatarUrl
		}).then(res= > {
			this.login(res);
			this.$isResolve();
		}).catch(e= > {
			console.log('login error');
			this.$isResolve();
		});
	}else {
		// Tips: Cancel the mandatory login if the wechat verification fails
		// Go to the login page immediately
		// uni.redirectTo({
		// url: '/pages/login/index'
		// });
		this.$isResolve(); }}Copy the code

3. Use the onLoad method

async onLoad(option) {
	console.log('detail show');
	// Option is of type object, which serializes the parameters passed on the previous page
	const uuid = option.scene
	// Wait for the login to succeed
	await this.$onLaunched;
	if(!this.hasLogin) {
		this.show = true;
	} else{
		// Authorize login
		if(uuid && uuid.length === 32) {
			this.authInfo.uuid = uuid
			// Obtain user information
			this.getUserToken()
			await this.scannQrcode(uuid)
			this.authInfo.showAuth = true}}}Copy the code

Results 3.

After testing, this Bug has been resolved. If you are interested, you can try it yourself

Four,

After writing a few short blog posts in the community, we now have 110+ users. Thank you here for registering Jane account, thank you 😊 if you think my project is good, might as well give my Github point a Star♥