123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- import App from './App'
- import md5Libs from "./uview-ui/libs/function/md5.js";
- import url from "./common/url.js"
- // #ifndef VUE3
- import Vue from 'vue'
- import Socket from "./common/websocket.js"
- var amapFile = require('./common/amap-wx.js');
- Vue.prototype.$Socket = Socket
- Vue.prototype.$tologin = function(msg){
- if (msg == '请登录。' || msg == '账号在其他地方登录,请重新登录。'){
- uni.removeStorageSync("token")
- setTimeout(() => {
- uni.navigateTo({
- url:"/pages/mine/login-wx"
- })
- },800)
- }
- },
- Vue.prototype.myAmapFun = new amapFile.AMapWX({
- key: 'daba801a5b8eb18e2aee6d0838ea4c61'
- });
- Vue.prototype.$md5 = md5Libs.md5
- Vue.prototype.$url = url
- Vue.prototype.$openimg = function(arr, count = 0) {
- uni.previewImage({
- urls: arr,
- current: count
- })
- }
- Vue.prototype.$tophone = function(tel, str) {
- if (str) {
- this.$u.toast(str)
- } else {
- uni.makePhoneCall({
- phoneNumber: tel
- })
- }
- }
- Vue.prototype.$openad = function(obj) {
- // 广告类型(1、类别;2、服务;3、链接;4、商家;5、文章;6、关键字;7水电服务,8呼叫代驾,9跑腿服务,10申请服务,11商城,12商城商品,13查看大图)
- if (obj.advertise_type == 5) {
- uni.navigateTo({
- url: "/pages/index/wenzhang?id=" + obj.source_code
- })
- return
- }
- if (obj.advertise_type == 7) {
- uni.navigateTo({
- url: "/pages/index/weixiu"
- })
- return
- }
- if (obj.advertise_type == 8) {
- uni.navigateTo({
- url: "/pages/index/daijia"
- })
- return
- }
- if (obj.advertise_type == 9) {
- uni.navigateTo({
- url: "/pages/index/paotui"
- })
- return
- }
- if (obj.advertise_type == 11) {
- uni.switchTab({
- url: "/pages/shop/shop"
- })
- return
- }
- if (obj.advertise_type == 12) {
- uni.navigateTo({
- url: "/pages/shop/goods-info?id=" + obj.business_product.id
- })
- return
- }
- uni.showModal({
- content: `新的type=${obj.advertise_type}`
- })
- console.log(obj);
- }
- Vue.prototype.$getdata = function() {
- var timestamp = parseInt(new Date().getTime() / 1000)
- var secret_key = 'cXab5HR4pfBjdDryr2JjwbreieKVjA'
- var params = {}
- var str = '';
- for (var Key in params) {
- str += Key + '=' + params[Key] + '&';
- }
- var sign = md5Libs.md5(`${str}timestamp=${timestamp}&secret_key=${secret_key}`)
- // console.log(`${str}timestamp=${timestamp}&secret_key=${secret_key}`);
- var phonetype = uni.getSystemInfoSync().model
- var header = {}
- header.sign = sign
- header.timestamp = timestamp
- header.phonetype = phonetype
- header.category = 3
- header.secret_key = secret_key
- header.token = uni.getStorageSync('token');
- // config.data.header.debug = "5CDAC27A0F89C916553DE870F3C55181"//默认登录
- return {
- request: JSON.stringify({
- header: header
- })
- }
- }
- Vue.prototype.$opencode = function() {
- // if (!uni.getStorageSync("token")) {
- // this.$u.toast("请登录")
- // setTimeout(() => {
- // uni.navigateTo({
- // url: "/pages/mine/login-wx"
- // })
- // }, 800)
- // return
- // }
- uni.scanCode({
- success: (res) => {
- console.log(res);
- var query = res.result.split("?")[1]
- if (query) {
- var vars = query.split("&");
- var xiaoma_type
- for (var i = 0; i < vars.length; i++) {
- var pair = vars[i].split("=");
- if (pair[0] == 'xiaoma_type') {
- xiaoma_type = pair[1]
- }
- }
- for (var i = 0; i < vars.length; i++) {
- var pair = vars[i].split("=");
- if (pair[0] == 'xiaoma_code') {
- // 去核销
- if (xiaoma_type == 7) {
- uni.navigateTo({
- url: "/pages/shop/shop-orderinfo?url=" + pair[1]
- })
- }
- // 去注册
- if (xiaoma_type == 2) {
- if (uni.getStorageSync("token")) {
- this.$u.toast("当前账户已被邀请")
- } else {
- uni.showModal({
- content: "邀请码:" + pair[1],
- confirmText: "去注册",
- success: (on) => {
- if (on.confirm) {
- uni.navigateTo({
- url: "/pages/mine/login-wx?yqm=" + pair[1]
- })
- }
- }
- })
- }
- }
- return;
- }
- }
- this.$u.toast('缺少参数')
- } else {
- this.$u.toast('缺少参数')
- }
- },
- fail(e) {
- // uni.showModal({
- // content:JSON.stringify(e)
- // })
- }
- })
- }
- uni.$tabbar = [{
- "iconPath": "/static/images/index1.png",
- "selectedIconPath": "/static/images/index.png",
- "pagePath": "/pages/index/home",
- "text": "主页"
- },
- {
- "iconPath": "/static/images/order1.png",
- "selectedIconPath": "/static/images/order.png",
- "pagePath": "/pages/order/order",
- "text": "订单",
- "count": 0
- },
- // {
- // "iconPath": "/static/images/shop1.png",
- // "selectedIconPath": "/static/images/shop.png",
- // "pagePath": "/pages/shop/shop",
- // "text": "商城"
- // },
- {
- "iconPath": "/static/images/mine1.png",
- "selectedIconPath": "/static/images/mine.png",
- "pagePath": "/pages/mine/mine",
- "text": "我的"
- }
- ]
- // main.js
- import uView from 'uview-ui';
- Vue.use(uView);
- Vue.config.productionTip = false
- App.mpType = 'app'
- const app = new Vue({
- ...App
- })
- // http拦截器,此为需要加入的内容,如果不是写在common目录,请自行修改引入路径
- import httpInterceptor from '@/common/http.interceptor.js'
- // 这里需要写在最后,是为了等Vue创建对象完成,引入"app"对象(也即页面的"this"实例)
- Vue.use(httpInterceptor, app)
- app.$mount()
- // #endif
- // #ifdef VUE3
- import {
- createSSRApp
- } from 'vue'
- export function createApp() {
- const app = createSSRApp(App)
- return {
- app
- }
- }
- // #endif
|