| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- /**
- * 拨打电话
- *
- */
- export const MakePhoneCall = (tel) => {
- if (!tel) {
- uni.showToast({
- title: '暂未设置电话号码',
- icon: 'none'
- });
- return;
- }
- uni.makePhoneCall({
- phoneNumber: tel,
- fail: () => {
- // uni.showToast({
- // title: '暂未设置电话号码',
- // icon: false
- // });
- }
- });
- };
- /**
- * 地图导航
- * location:商家位置
- * provinceName:所属省名
- * cityName:所属市名
- * areaName:所属区名
- * address:详细地址
- * latitude:纬度
- * longitude:经度
- */
- export const MapNavigation = (vo) => {
- const {
- location,
- provinceName,
- cityName,
- areaName,
- address,
- latitude,
- longitude
- } = vo;
- // console.log('MapNavigation', vo);
- // uni.showToast({
- // title: '开发中',
- // icon: 'none'
- // });
- uni.openLocation({
- latitude: latitude * 1,
- longitude: longitude * 1,
- name: address,
- success: function () {
- // console.log('success');
- }
- });
- }
- // 获取今天时间
- type FormatTs = 'YYYYMMDD' | 'YYYYMMDDhhmmss' | 'YYYYMMDDhhmm';
- const Zero = (num) => {
- return num >= 10 ? num : `0${num}`
- }
- interface TimeTs {
- time?: any
- format?: 'YYYYMMDD' | 'YYYYMMDDhhmmss' | 'YYYYMMDDhhmm' | 'MMDD',
- joint?: '/' | '-'
- }
- export const oneDay = 60 * 60 * 24 * 1000; // 一天的时间
- export const getTimeVal = (params: TimeTs = {}) => {
- const { time, format, joint = '-' } = params || {}
- // console.log("time, format, joint = ", params)
- // { format: FormatTs, joint = '/' }
- const Time_ = time ? new Date(time) : new Date();
- let Time_Str: any = '';
- if (format) {
- const Y = Time_.getFullYear();
- const M = Zero(Time_.getMonth() + 1);
- const D = Zero(Time_.getDate());
- const h = Zero(Time_.getHours());
- const m = Zero(Time_.getMinutes());
- const s = Zero(Time_.getSeconds());
- // console.log('Y ===== ', Y, M)
- switch (format) {
- case 'MMDD':
- Time_Str = `${M}${joint}${D}`;
- break;
- case 'YYYYMMDD':
- Time_Str = `${Y}${joint}${M}${joint}${D}`;
- break;
- case 'YYYYMMDDhhmm':
- Time_Str = `${Y}${joint}${M}${joint}${D} ${h}:${m}`;
- break;
- case 'YYYYMMDDhhmmss':
- Time_Str = `${Y}${joint}${M}${joint}${D} ${h}:${m}:${s}`;
- break;
- default:
- Time_Str = Time_.getTime()
- }
- } else {
- Time_Str = Time_.getTime()
- };
- // console.log('Time_Str = ', Time_Str)
- return Time_Str
- }
- export const copyData = (text) => {
- if (!text) {
- uni.showToast({
- title: "复制内容不能为空",
- icon: 'none'
- })
- } else {
- uni.setClipboardData({
- data: text,
- success: () => {
- uni.showToast({
- title: "复制成功",
- icon: 'none'
- })
- },
- fail: () => {
- uni.showToast({
- title: "复制失败",
- icon: 'none'
- })
- }
- });
- }
- }
|