| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- import {addlog} from "@/common/api/system.js"
- /**
- * @param {Object} type error info success
- * @param {Object} message
- */
- export function showsysteinfo(type,message){
- let icon =success
- switch(type){
- case "error":
- icon="success";
- break;
- case "info":
- icon="none";
- break;
- case "success":
- icon="success";
- break;
- }
- uni.showToast({
- title: message,
- icon:icon,
- duration: 2000
- });
- }
- export function islogin(){
- let userinfo = uni.getStorageSync("userinfo");
- if(!userinfo){
- return false;
- }
- return true
- }
- export function saveuserinfo(info){
- uni.setStorage({
- key: 'userinfo',
- data: info,
- success: function () {
- },
- fail:function(error){
- console.log('error');
- addlog({
- json: "用户信息保存失败",
- type: 'uniapp错误'
- })
- }
- });
- }
- /**
- * 清除缓存
- */
- export function clear(){
- try {
- uni.clearStorageSync();
- } catch (e) {
- showsysteinfo('error',"操作失败")
- addlog({
- json: "缓存清理失败",
- type: 'uniapp错误'
- })
- }
- }
- export function tostemlistnext(startindex,next=0,scaleid_1=false,srid_1=false){
- startindex = parseInt(startindex)+next
- let stemlist = uni.getStorageSync('stemlist')
-
- if(!stemlist){
- return false
- }
- let item = stemlist[startindex]
- //console.log(item)
- if(!item){
- return false
- }
- uni.setStorage({
- key: 'stemitem',
- data: item
- });
- if(item==undefined){
- return false
- }
- if(scaleid_1!==false&&srid_1!==false){
- if(item.stemtype<101){
- //标准答题
- uni.navigateTo({
- url: '/pages/topic/common'+"?scaleid="+scaleid_1 + "&srid=" + srid_1 + `&sindex=` + startindex
- });
- }else{
- //特殊答题
- let url = "/pages/topic/"+item.stemdefinepage+"?scaleid="+scaleid_1 + "&srid=" + srid_1 + `&sindex=` + startindex
- uni.navigateTo({
- url: url
- });
- }
- }else{
- let scaleid=4
- let srid = uni.getStorageSync('srid')
- if(item.stemtype<101){
- //标准答题
- uni.navigateTo({
- url: '/pages/topic/common'+"?scaleid="+scaleid + "&srid=" + srid + `&sindex=` + startindex
- });
- }else{
- //特殊答题
- let url = "/pages/topic/"+item.stemdefinepage+"?scaleid="+scaleid + "&srid=" + srid + `&sindex=` + startindex
- uni.navigateTo({
- url: url
- });
- }
- }
- return true
- }
- export function tohome(){
- uni.redirectTo({
- url: '/pages/index/index'
- });
- }
|