uniapp answer exam framework summary

I am a micro-channel public number originally developed a test system, using a uniapp framework, I am here for a framework interface package, we are here to back-end information appId uid and related micro-channel authorization are back-end processing, to I am here I only got a token, the background check.
I am here to do is to verify is whether to open a micro letter, to facilitate the development, I used the natapp to test development

Judgment is not micro-channel client opens here is the back-end authorization information to my address, they will be redirected to the page I threw the token value in the address bar above

			var ua = window.navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == 'micromessenger') {
				//由于是启动页面,所以设置个延迟 1.5s后再进入授权页面
				setTimeout(function() {
					// 在进入主页之前获取权限调用接口存一下token
					// var url = ""; 
					// window.location.href = url;
				}, 1500)
			} else {
				alert("请在微信客户端打开链接")
			}

I get token from the address bar, quite simply, is that they give the format: https: //xxxx.com token = xxxx, uniapp own method?

  onLoad(option){
    this.token=option.token
  }

About landing rights if I am my own package interface (bottom of article I'll put my template address), and here we are back with a header token is received, and the need to discuss with you a background. Look willing to waste two minutes to give you a return error, the wrong time, or if the token is a token expired when returns a status code to determine this status code wrong or out of date when he returned to the directly to the start page, let him obtain authorization token, to obtain complete token to prevent loss, my side is there is a time localStorage with uni.getStorageSync ( 'token') to acquire, and then go directly to the token encapsulated in the package interface will be called in each token to get localStorage give yourself every time you do not have the background to the header pass
ps: baseUrl package interface plugins directory / read is dynamically obtained from commponents in the config.js where
basically you took this framework put things page deleted on the line, the interface you use enough to use directly; do not forget to mount it on the Vue method

main.js under

import Request from './plugins/request/index'
Vue.prototype.$http = Request();

Use the following method

this.$http.request({
						url: '/time', //请求地址
						method: '', //请求类型 我接口请求方法默认设置的是post因为后台都是post 我就不用写menthod了
						// params: {},//设置QueryString [Object] 如果需要以QueryString格式就用这个传参
						// data:{}, //请求的参数 [Object]
						// header:{} //请求的header token我已经在方法里弄了 我一般只写一个url 和传参的data
					}).then(res => {
							console.log(res)
							}).catch(err => {
							console.log(err);
						})
					},

In addition uniapp click on a data tag content copy data download ican-H5Api (template below me with the address where there)

getWeChatId(val) {
				uni.setClipboardData({
					data: val,
					success: function(data) {
						console.log(data);
					},
					fail: function(err) {},
					complete: function(res) {}
				})
				uni.getClipboardData({
					success: function(data) {
						uni.showToast({
						    title: '复制成功',
						    duration: 1000
						});
					},
					fail: function(err) {},
					complete: function(res) {}
				})
			}

Here Insert Picture Description
I am here also encapsulates the components of a formatted time (I have previously written articles look through it) which are written to use the method above, there are

I do answer here is (as well as after completion of the answer choice to select the answer was an error of judgment on the case on a red background is green)
as well as color and answer sheet to answer the conversion of the current state of the collection of selected topics judgment is light blue

Here Insert Picture Description
Here Insert Picture Description

Has the answer correct answer when blue, pink is the wrong answer, the current title is yellow

Here Insert Picture Description

Of course there are no judge of the page (/ pages / practice / simulationExam / answer) in this countdown page, there are notes like method
developed by the authors is not easy to give attention to a praise it I will continue to share resources. I'm just a big white God, do not spray
template bug in a timely style private letter I question you have to do to solve it.

Click the link into the address template

Published 41 original articles · won praise 2 · Views 1348

Guess you like

Origin blog.csdn.net/weixin_44128575/article/details/104674769