res = await request(orderList, options); | res = await request(orderList, options); | ||||
const data = stringToJson(res.bizContent); | const data = stringToJson(res.bizContent); | ||||
console.log("ordersList.value", ordersList.value) | console.log("ordersList.value", ordersList.value) | ||||
// 订单发货后未激活 30天 以后 结束订单功能 insertTime >30 | |||||
// 订单发货后未激活 30天 以后 结束订单功能 insertTime >30 算出来距离今天是负数 | |||||
for (var k = 0; k < ordersList.value.length; k++) { | for (var k = 0; k < ordersList.value.length; k++) { | ||||
console.log("ordersList.value1111", ordersList.value[k]['insertTime'].replace("T", " ")) | console.log("ordersList.value1111", ordersList.value[k]['insertTime'].replace("T", " ")) | ||||
console.log("ordersList.value1111", timesDiff(ordersList.value[k]['insertTime'].replace("T", " "))) | console.log("ordersList.value1111", timesDiff(ordersList.value[k]['insertTime'].replace("T", " "))) | ||||
if (ordersList.value[k]['insertTime']) { | if (ordersList.value[k]['insertTime']) { | ||||
if (timesDiff(ordersList.value[k]['insertTime'].replace("T", " ")).days <= -30) { | |||||
if (timesDiff(ordersList.value[k]['insertTime'].replace("T", " ")).days > 30) { | |||||
ordersList.value[k]['finishOrder'] = true //可以结束 | ordersList.value[k]['finishOrder'] = true //可以结束 | ||||
} else { | } else { | ||||
ordersList.value[k]['finishOrder'] = false //不可以结束 | ordersList.value[k]['finishOrder'] = false //不可以结束 | ||||
} | } | ||||
} | } | ||||
if (ordersList.value[k]['updateTime']) { | if (ordersList.value[k]['updateTime']) { | ||||
if (timesDiff(ordersList.value[k]['updateTime'].replace("T", " ")).days <= -30) { | |||||
if (timesDiff(ordersList.value[k]['updateTime'].replace("T", " ")).days <= 30) { | |||||
ordersList.value[k]['isUseAgain'] = true //可以再次使用 | ordersList.value[k]['isUseAgain'] = true //可以再次使用 | ||||
} else { | } else { | ||||
ordersList.value[k]['isUseAgain'] = false //不可以再次使用 | ordersList.value[k]['isUseAgain'] = false //不可以再次使用 |
<script setup lang="ts"> | <script setup lang="ts"> | ||||
import { reactive } from "vue"; | import { reactive } from "vue"; | ||||
import { checkStr, msg, navTo } from "@/utils/utils"; | |||||
import { checkStr, msg, navTo, subscribeMessages } from "@/utils/utils"; | |||||
import { onLoad, onUnload } from "@dcloudio/uni-app"; | import { onLoad, onUnload } from "@dcloudio/uni-app"; | ||||
import { login, loginCode, loginTime, wechatAppID } from "@/utils/network/api.js"; | import { login, loginCode, loginTime, wechatAppID } from "@/utils/network/api.js"; | ||||
import { request } from "@/utils/network/request.js"; | import { request } from "@/utils/network/request.js"; | ||||
subscribeMessages(); | subscribeMessages(); | ||||
msg("登录成功!"); | msg("登录成功!"); | ||||
uni.$emit("refreshOrder"); | uni.$emit("refreshOrder"); | ||||
uni.navigateBack(); | |||||
// uni.navigateBack(); | |||||
uni.switchTab({ | |||||
url: '/pages/index/index' | |||||
}) | |||||
}); | }); | ||||
}); | }); | ||||
}; | }; | ||||
// 订阅消息 | |||||
const subscribeMessages = () => { | |||||
uni.requestSubscribeMessage({ | |||||
tmplIds: ['aNr4T2JEtaLtR9dihM2w3NAznz4bFMkutVZCbaSTjxg'], | |||||
success(res) { | |||||
console.log("订阅消息", res) | |||||
} | |||||
}) | |||||
} | |||||
</script> | </script> | ||||
<style lang="scss" scoped> | <style lang="scss" scoped> |
} | } | ||||
}, | }, | ||||
{ | { | ||||
"path" : "account-opening-template/account-opening-template", | |||||
"style" : | |||||
{ | |||||
"navigationBarTitleText" : "", | |||||
"enablePullDownRefresh" : false | |||||
"path": "account-opening-template/account-opening-template", | |||||
"style": { | |||||
"navigationBarTitleText": "", | |||||
"enablePullDownRefresh": false | |||||
} | } | ||||
} | } | ||||
] | ] | ||||
} | } | ||||
} | } | ||||
}, | }, | ||||
{ | |||||
"path": "takePhoto", | |||||
"style": { | |||||
"navigationBarTitleText": "" | |||||
} | |||||
}, | |||||
{ | { | ||||
"path": "changeInformation", | "path": "changeInformation", | ||||
"style": { | "style": { |
</view> | </view> | ||||
<!-- 待激活 --> | <!-- 待激活 --> | ||||
<view class="btns" v-else-if="item.orderStep == OrderStatus.待激活"> | |||||
<view class="btns" v-else-if="item.orderStep == OrderStatus.待激活 "> | |||||
<view class="btn btn-normal" @click.stop="gotoReturnOrder(item)">申请退货</view> | <view class="btn btn-normal" @click.stop="gotoReturnOrder(item)">申请退货</view> | ||||
<view class="btn btn-normal" @click.stop="gotoExchangeOrder(item)">申请换货</view> | <view class="btn btn-normal" @click.stop="gotoExchangeOrder(item)">申请换货</view> | ||||
<view class="btn btn-primary" @click.stop="gotoActiveOrder(item)">去激活 | |||||
</view> | |||||
<view class="btn btn-primary" @click.stop="gotoActiveOrder(item)">去激活</view> | |||||
<view class="btn btn-primary" @click.stop="closeOrder(item)" v-if="item.finishOrder">结束订单</view> | |||||
</view> | </view> | ||||
<!-- 已完成 --> | <!-- 已完成 --> | ||||
</view> | </view> | ||||
</view> | </view> | ||||
<!-- 结束订单 --> | <!-- 结束订单 --> | ||||
<view class="btns" v-else-if="item.orderStep == OrderStatus.待激活 && item.finishOrder"> | |||||
<!-- <view class="btns" v-else-if="item.orderStep == OrderStatus.待激活 && item.finishOrder"> | |||||
<view class="btn btn-primary" @click.stop="closeOrder(item)">结束订单</view> | <view class="btn btn-primary" @click.stop="closeOrder(item)">结束订单</view> | ||||
</view> | |||||
</view> --> | |||||
<!-- 已结束 --> | <!-- 已结束 --> | ||||
<view class="btns" v-else-if="item.orderStep == OrderStatus.已结束 && item.isUseAgain"> | <view class="btns" v-else-if="item.orderStep == OrderStatus.已结束 && item.isUseAgain"> | ||||
<!-- <view class="btn btn-primary" @click.stop="showActiveOrder = true">重新激活订单</view> --> <!-- 以前的 --> | <!-- <view class="btn btn-primary" @click.stop="showActiveOrder = true">重新激活订单</view> --> <!-- 以前的 --> |
console.log("state.data.opId", state.data.opId) | console.log("state.data.opId", state.data.opId) | ||||
if (state.data.opId) { | if (state.data.opId) { | ||||
getUserInfo(); | getUserInfo(); | ||||
} else { | |||||
state.userVehicleInfoSumQueryVo = { | |||||
vehicleSum: 0, | |||||
orderStatus0: 0 | |||||
} | |||||
state.monthFlowingVo = { | |||||
duration: 0, | |||||
mileage: 0, | |||||
flowingNum: 0, | |||||
num: 0, | |||||
parkingLotMoney: 0, | |||||
parkingLotNum: 0, | |||||
money: 0, | |||||
}, | |||||
state.list = [], | |||||
state.carNumber = 0 | |||||
} | } | ||||
}); | }); | ||||
// 查询车辆信息 | // 查询车辆信息 | ||||
openId: state.data.opId | openId: state.data.opId | ||||
}, | }, | ||||
method: "POST", | method: "POST", | ||||
// showLoading: true, | |||||
showLoading: true, | |||||
}; | }; | ||||
//调用方式 | //调用方式 | ||||
request(userInfoIndex, options) | request(userInfoIndex, options) |
const takePhoto = (val) => { | const takePhoto = (val) => { | ||||
console.log("拍照", val) | console.log("拍照", val) | ||||
state.phoneType = val; | state.phoneType = val; | ||||
state.showImg = true; | |||||
} | } | ||||
const confirmReturn = (val) => { | const confirmReturn = (val) => { | ||||
if (state.choiceIndex == 3) { | if (state.choiceIndex == 3) { |
const takePhoto = (val) => { | const takePhoto = (val) => { | ||||
console.log("拍照", val) | console.log("拍照", val) | ||||
state.phoneType = val; | state.phoneType = val; | ||||
state.showImg = true; | |||||
} | } | ||||
const confirmReturn = (val) => { | const confirmReturn = (val) => { | ||||
if (state.choiceIndex == 3) { | if (state.choiceIndex == 3) { |
const takePhoto = (val) => { | const takePhoto = (val) => { | ||||
console.log("拍照", val) | console.log("拍照", val) | ||||
state.phoneType = val; | state.phoneType = val; | ||||
state.showImg = true; | |||||
} | } | ||||
const confirmReturn = (val) => { | const confirmReturn = (val) => { | ||||
if (state.choiceIndex == 3) { | if (state.choiceIndex == 3) { |
const takePhoto = (val) => { | const takePhoto = (val) => { | ||||
console.log("拍照", val) | console.log("拍照", val) | ||||
state.phoneType = val; | state.phoneType = val; | ||||
state.showImg = true; | |||||
} | } | ||||
const confirmReturn = (val) => { | const confirmReturn = (val) => { | ||||
if (state.choiceIndex == 3) { | if (state.choiceIndex == 3) { |
} else if (n == '储值卡') { | } else if (n == '储值卡') { | ||||
state.isValueCard = 1 | state.isValueCard = 1 | ||||
} else { | } else { | ||||
state.isValueCard = 3 | |||||
state.isValueCard = 2 | |||||
} | } | ||||
uni.redirectTo({ | uni.redirectTo({ | ||||
url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`, | url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`, | ||||
for (var i = 0; i < state.dataArray.length; i++) { | for (var i = 0; i < state.dataArray.length; i++) { | ||||
const cardTypeArr = [] | const cardTypeArr = [] | ||||
for (var j = 0; j < state.dataArray[i]['releaseProductStandards']['productStandards'].cardType.length; j++) { | for (var j = 0; j < state.dataArray[i]['releaseProductStandards']['productStandards'].cardType.length; j++) { | ||||
if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '1') { | |||||
if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '2') { | |||||
cardTypeArr.push('储值卡') | cardTypeArr.push('储值卡') | ||||
} else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '2') { | |||||
} else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '1') { | |||||
cardTypeArr.push('记账卡') | cardTypeArr.push('记账卡') | ||||
} else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '3') { | } else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '3') { | ||||
cardTypeArr.push('预存卡') | cardTypeArr.push('预存卡') | ||||
state.dataArray = state.dataArray.filter(function (e) { | state.dataArray = state.dataArray.filter(function (e) { | ||||
console.log("e", e['releaseProductStandards']['productStandards']['cardType']) | console.log("e", e['releaseProductStandards']['productStandards']['cardType']) | ||||
for (var i = 0; i < e['releaseProductStandards']['productStandards']['cardType'].length; i++) { | for (var i = 0; i < e['releaseProductStandards']['productStandards']['cardType'].length; i++) { | ||||
if (e['releaseProductStandards']['productStandards']['cardType'][i] == "2") { | |||||
if (e['releaseProductStandards']['productStandards']['cardType'][i] == "1") { | |||||
return e['releaseProductStandards']['productStandards']['cardType']; | return e['releaseProductStandards']['productStandards']['cardType']; | ||||
} | } | ||||
} | } |
const takePhoto = (val) => { | const takePhoto = (val) => { | ||||
console.log("拍照", val) | console.log("拍照", val) | ||||
state.phoneType = val; | state.phoneType = val; | ||||
state.showImg = true; | |||||
} | } | ||||
const confirmReturn = (val) => { | const confirmReturn = (val) => { | ||||
if (state.choiceIndex == 3) { | if (state.choiceIndex == 3) { |
} else if (n == '储值卡') { | } else if (n == '储值卡') { | ||||
state.isValueCard = 1 | state.isValueCard = 1 | ||||
} else { | } else { | ||||
state.isValueCard = 3 | |||||
state.isValueCard = 2 | |||||
} | } | ||||
// uni.redirectTo({ | // uni.redirectTo({ | ||||
// url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`, | // url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`, | ||||
} else if (val['releaseProductStandards']['productStandards']['cardTypeArr'].split(",")[0] == '储值卡') { | } else if (val['releaseProductStandards']['productStandards']['cardTypeArr'].split(",")[0] == '储值卡') { | ||||
state.isValueCard = 1 | state.isValueCard = 1 | ||||
} else { | } else { | ||||
state.isValueCard = 3 | |||||
state.isValueCard = 2 | |||||
} | } | ||||
console.log("state.isValueCard", state.isValueCard) | console.log("state.isValueCard", state.isValueCard) | ||||
setItem("isValueCard", state.isValueCard); | setItem("isValueCard", state.isValueCard); | ||||
for (var i = 0; i < state.dataArray.length; i++) { | for (var i = 0; i < state.dataArray.length; i++) { | ||||
const cardTypeArr = [] | const cardTypeArr = [] | ||||
for (var j = 0; j < state.dataArray[i]['releaseProductStandards']['productStandards'].cardType.length; j++) { | for (var j = 0; j < state.dataArray[i]['releaseProductStandards']['productStandards'].cardType.length; j++) { | ||||
if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '1') { | |||||
if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '2') { | |||||
cardTypeArr.push('储值卡') | cardTypeArr.push('储值卡') | ||||
} else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '2') { | |||||
} else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '1') { | |||||
cardTypeArr.push('记账卡') | cardTypeArr.push('记账卡') | ||||
} else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '3') { | } else if (state.dataArray[i]['releaseProductStandards']['productStandards'].cardType[j] == '3') { | ||||
cardTypeArr.push('预存卡') | cardTypeArr.push('预存卡') |
} else if (n == '储值卡') { | } else if (n == '储值卡') { | ||||
state.isValueCard = 1 | state.isValueCard = 1 | ||||
} else { | } else { | ||||
state.isValueCard = 3 | |||||
state.isValueCard = 2 | |||||
} | } | ||||
uni.redirectTo({ | uni.redirectTo({ | ||||
url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`, | url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isSign=${state.isSign}&isValueCard=${state.isValueCard}`, |
<template> | |||||
<view> | |||||
<viewfinder :phoneType="state.phoneType" @confirmReturn="confirmReturn"></viewfinder> | |||||
</view> | |||||
</template> | |||||
<script setup lang="ts"> | |||||
import viewfinder from "../../components/viewfinder.vue" | |||||
import { | |||||
onLoad | |||||
} from "@dcloudio/uni-app"; | |||||
import { | |||||
reactive | |||||
} from "vue"; | |||||
const state = reactive({ | |||||
phoneType: 1, | |||||
allParams: {} | |||||
}) | |||||
onLoad((option : any) => { | |||||
state.phoneType = option.phoneType; | |||||
state.allParams = option.allParams; | |||||
}); | |||||
const confirmReturn = (val) => { | |||||
// uni.navigateTo({ | |||||
// url: `` | |||||
// }) | |||||
uni.navigateBack({ | |||||
delta: 1 | |||||
}) | |||||
console.log("val", val) | |||||
} | |||||
</script> | |||||
<style> | |||||
.content { | |||||
display: flex; | |||||
flex-direction: column; | |||||
align-items: center; | |||||
justify-content: center; | |||||
} | |||||
.logo { | |||||
height: 200rpx; | |||||
width: 200rpx; | |||||
margin-top: 200rpx; | |||||
margin-left: auto; | |||||
margin-right: auto; | |||||
margin-bottom: 50rpx; | |||||
} | |||||
.text-area { | |||||
display: flex; | |||||
justify-content: center; | |||||
} | |||||
.title { | |||||
font-size: 36rpx; | |||||
color: #8f8f94; | |||||
} | |||||
</style> |
<script setup lang="ts"> | <script setup lang="ts"> | ||||
import { reactive } from "vue"; | import { reactive } from "vue"; | ||||
import { checkStr, msg, navTo } from "@/utils/utils"; | |||||
import { checkStr, msg, navTo, subscribeMessages } from "@/utils/utils"; | |||||
import { onLoad, onUnload } from "@dcloudio/uni-app"; | import { onLoad, onUnload } from "@dcloudio/uni-app"; | ||||
import { checkCode } from "@/utils/network/api.js"; | |||||
import { checkCode, loginCode, loginTime } from "@/utils/network/api.js"; | |||||
import { request } from "@/utils/network/request.js"; | import { request } from "@/utils/network/request.js"; | ||||
import { stringToJson } from "@/utils/network/encryption"; | import { stringToJson } from "@/utils/network/encryption"; | ||||
import { useUserStore } from "@/stores/user"; | import { useUserStore } from "@/stores/user"; | ||||
console.log(q); | console.log(q); | ||||
state.json = getRequest(q) | state.json = getRequest(q) | ||||
console.log("state.json", state.json, getItem("mobile"), getItem("mobile") == state.json.phone) | console.log("state.json", state.json, getItem("mobile"), getItem("mobile") == state.json.phone) | ||||
setItem('scanCode', state.json) | |||||
if (!getItem("mobile")) { | |||||
uni.showModal({ | |||||
title: '提示', | |||||
content: '您还未登录小程序,请先登录小程序', | |||||
showCancel: false, | |||||
success: function (res) { | |||||
if (res.confirm) { | |||||
navTo('/login/login') | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
// setItem('scanCode', state.json) | |||||
// if (!getItem("mobile")) { | |||||
// uni.showModal({ | |||||
// title: '提示', | |||||
// content: '您还未登录小程序,请先登录小程序', | |||||
// showCancel: false, | |||||
// success: function (res) { | |||||
// if (res.confirm) { | |||||
// navTo('/login/login') | |||||
// } | |||||
// } | |||||
// }); | |||||
// } | |||||
// 直接用传过来的手机号(不让他修改) | // 直接用传过来的手机号(不让他修改) | ||||
state.mobile = state.json.phone | state.mobile = state.json.phone | ||||
} else { | } else { | ||||
msg("请输入正确的手机号!"); | msg("请输入正确的手机号!"); | ||||
return; | return; | ||||
} | } | ||||
// 直接去登录 | |||||
reqLogin(loginCode, { | |||||
mobile: state.mobile, | |||||
code: state.code, | |||||
loginTime: loginTime, | |||||
}); | |||||
}; | |||||
/* 执行登录 */ | |||||
const reqLogin = (code : string, data : object) => { | |||||
console.log(code, data); | |||||
const options = { | const options = { | ||||
type: 2, | type: 2, | ||||
data: { | |||||
mobile: state.mobile, | |||||
code: state.code | |||||
}, | |||||
data: data, | |||||
method: "POST", | method: "POST", | ||||
showLoading: true, | showLoading: true, | ||||
}; | }; | ||||
request(checkCode, options).then((res) => { | |||||
console.log("过来了", res) | |||||
// type 1扫码支付 2扫描协议确认 | |||||
if (state.json.type == 1) { | |||||
uni.navigateTo({ | |||||
url: `/subpackage/orders/order_payment?orderId=${state.json.orderId}`, | |||||
}); | |||||
} else if (state.json.type == 2) { | |||||
uni.navigateTo({ | |||||
url: `/subpackage/orders/product-detail?orderId=${state.json.orderId}&url=${state.json.url}&typeScanCode=${state.json.type}`, | |||||
}); | |||||
} | |||||
}) | |||||
.catch((err) => { | |||||
// msg("验证码错误"); | |||||
request(code, options).then((res) => { | |||||
const result = stringToJson(res.bizContent); | |||||
console.log(result); | |||||
console.log(typeof (result)); | |||||
fetchToken(result.code).then((data : any) => { | |||||
console.log("登录", data); | |||||
setItem('mobile', state.mobile) | |||||
subscribeMessages(); | |||||
if (state.json.type == 1) { | |||||
uni.navigateTo({ | |||||
url: `/subpackage/orders/order_payment?orderId=${state.json.orderId}`, | |||||
}); | |||||
} else if (state.json.type == 2) { | |||||
uni.navigateTo({ | |||||
url: `/subpackage/orders/product-detail?orderId=${state.json.orderId}&url=${state.json.url}&typeScanCode=${state.json.type}`, | |||||
}); | |||||
} | |||||
}); | }); | ||||
}); | |||||
}; | }; | ||||
//解析URL获取参数 | //解析URL获取参数 | ||||
const getRequest = (urlStr) => { | const getRequest = (urlStr) => { | ||||
if (typeof urlStr == "undefined") { | if (typeof urlStr == "undefined") { |
const takePhoto = (val) => { | const takePhoto = (val) => { | ||||
console.log("拍照", val) | console.log("拍照", val) | ||||
state.phoneType = val; | state.phoneType = val; | ||||
state.showImg = true; | |||||
} | } | ||||
const confirmReturn = (val) => { | const confirmReturn = (val) => { | ||||
if (state.choiceIndex == 3) { | if (state.choiceIndex == 3) { |
const takePhoto = (val) => { | const takePhoto = (val) => { | ||||
console.log("拍照", val) | console.log("拍照", val) | ||||
state.phoneType = val; | state.phoneType = val; | ||||
state.showImg = true; | |||||
} | } | ||||
const confirmReturn = (val) => { | const confirmReturn = (val) => { | ||||
state.phoneType = 0 | state.phoneType = 0 |
const takePhoto = (val) => { | const takePhoto = (val) => { | ||||
console.log("拍照", val) | console.log("拍照", val) | ||||
state.phoneType = val; | state.phoneType = val; | ||||
state.showImg = true; | |||||
} | } | ||||
const confirmReturn = (val) => { | const confirmReturn = (val) => { | ||||
state.phoneType = 0 | state.phoneType = 0 |
options.success = (res) => { | options.success = (res) => { | ||||
console.log('请求成功返回参数:', code, res) | console.log('请求成功返回参数:', code, res) | ||||
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading) | // 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading) | ||||
uni.hideLoading() | |||||
if (options.showLoading) { | |||||
uni.hideLoading() | |||||
} | |||||
if (res.data.statusCode !== 0) { | if (res.data.statusCode !== 0) { | ||||
if (res.data.statusCode == 600) { | if (res.data.statusCode == 600) { | ||||
resolve(res.data) | resolve(res.data) |
* @param {*} timesData '2018-05-17 16:58:00' | * @param {*} timesData '2018-05-17 16:58:00' | ||||
* @returns | * @returns | ||||
*/ | */ | ||||
export function timesDiff(timesData:any) { | |||||
var dateBegin = new Date();//获取当前时间 | |||||
var dateEnd = new Date(timesData.replace(/-/g, "/"));//将-转化为/,使用new Date | |||||
var dateDiff = dateEnd.getTime() - dateBegin.getTime();//时间差的毫秒数 | |||||
var days = Math.floor(dateDiff / (24 * 3600 * 1000));//计算出相差天数 | |||||
var leave1 = dateDiff % (24 * 3600 * 1000) //计算天数后剩余的毫秒数 | |||||
var hours = Math.floor(leave1 / (3600 * 1000))//计算出小时数 | |||||
var leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数 | |||||
var minutes = Math.floor(leave2 / (60 * 1000))//计算相差分钟数 | |||||
var diffObj = { | |||||
days: 0, | |||||
hours: 0, | |||||
minutes: 0, | |||||
}; | |||||
export function timesDiff(timesData : any) { | |||||
var dateBegin = new Date();//获取当前时间 | |||||
var dateEnd = new Date(timesData.replace(/-/g, "/"));//将-转化为/,使用new Date | |||||
var dateDiff = dateEnd.getTime() - dateBegin.getTime();//时间差的毫秒数 | |||||
var days = Math.floor(dateDiff / (24 * 3600 * 1000));//计算出相差天数 | |||||
var leave1 = dateDiff % (24 * 3600 * 1000) //计算天数后剩余的毫秒数 | |||||
var hours = Math.floor(leave1 / (3600 * 1000))//计算出小时数 | |||||
var leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数 | |||||
var minutes = Math.floor(leave2 / (60 * 1000))//计算相差分钟数 | |||||
var diffObj = { | |||||
days: 0, | |||||
hours: 0, | |||||
minutes: 0, | |||||
}; | |||||
if (days != 0) { | |||||
diffObj.days = days; | |||||
} else if (days == 0 && hours != 0) { | |||||
diffObj.hours = hours; | |||||
} else if (days == 0 && hours == 0) { | |||||
diffObj.minutes = minutes; | |||||
} | |||||
if (days != 0) { | |||||
diffObj.days = Math.abs(days); | |||||
} else if (days == 0 && hours != 0) { | |||||
diffObj.hours = hours; | |||||
} else if (days == 0 && hours == 0) { | |||||
diffObj.minutes = minutes; | |||||
} | |||||
return diffObj | |||||
return diffObj | |||||
} | |||||
// 订阅消息 | |||||
export function subscribeMessages() { | |||||
uni.requestSubscribeMessage({ | |||||
tmplIds: ['aNr4T2JEtaLtR9dihM2w3NAznz4bFMkutVZCbaSTjxg'], | |||||
success(res) { | |||||
console.log("订阅消息", res) | |||||
} | |||||
}) | |||||
} | } |