12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- // #ifndef VUE3
- import Vue from 'vue'
- import App from './App'
- // 导入网络请求的包
- import {
- $http
- } from '@escook/request-miniprogram'
- import {
- formatDate,
- sortASCII
- } from '@/utils.js'
- import crypto from 'crypto'
- Vue.config.productionTip = false
- App.mpType = 'app'
- uni.$http = $http
- // 请求的根路径
- $http.baseUrl = 'https://api.ijolijoli.com/'
- // 请求拦截器
- $http.beforeRequest = function(options) {
- // 当前发送请求时间
- let req_time = formatDate(new Date(), 'YYYYMMDDhhmmss')
- let app_id = '10020'
- let key = 'c2c1d3893504d063d7b30c0fc553c1b2'
- options.data.app_id=app_id
- options.data.req_time = req_time
- // 参数排序
- let sortObj = sortASCII(options.data, true)
- sortObj.key = key
- // 拼接参数
- let mdd = []
- let fnAdd = function(key, value) {
- return key + '=' + value
- }
- for (var k in sortObj) {
- mdd.push(fnAdd(k, sortObj[k]))
- }
- // 转成md5加密
- mdd=mdd.join('&')
- const md5 = crypto.createHash('md5')
- md5.update(mdd)
- const sign = md5.digest('hex')
- options.data.sign = sign
- }
- // 响应拦截器
- $http.afterRequest = function() {}
- const app = new Vue({
- ...App
- })
- app.$mount()
- // #endif
- // #ifdef VUE3
- import {
- createSSRApp
- } from 'vue'
- import App from './App.vue'
- import {
- log
- } from 'console'
- export function createApp() {
- const app = createSSRApp(App)
- return {
- app
- }
- }
- // #endif
|