2023.02.24(uniapp 问题记录)

一、有关页面点击不生效

图层问题 ---- 定位 position: relative; 取消

二、富文本 含图片及文字 渲染

正则 + 数组方法 +字符串方法

let url = 'https://qw.hzquanwan.com/uploads'
                    let arrlength = this.meansList.my_introduce.replace(/\/uploads/g,url).trim().split("</p>").length;
                    // this.my_introduce
                    let arr = this.meansList.my_introduce.replace(/\/uploads/g,url).trim().split("</p>").map(item=>item.concat("</p>")).slice(0,arrlength-1);
                    arr.forEach((item,index)=>{
                        if(item.indexOf("img") >= 0){
                            this.my_introduce_img.push(item)
                        }else{
                            this.my_introduce_des.push(item)
                        }
                    })

三、数组参数排序 sort

arr.sort(function(a, b) {
                        let value1 = a.is_top;
                        let value2 = b.is_top;
                        return value1 - value2;
                    })

四、带参返回上一页 uni.navigateTo() uni.navigateBack()

子页面 带参返回 prevPage.$vm.setData(参数)

var pages = getCurrentPages();
   var prevPage = pages[pages.length - 2]; //上一个页面
            prevPage.$vm.setData(); //重点$vm
            uni.navigateBack({
                delta: 1
            })

父页面 接收参数

setData(val){
                console.log(val)
        },

五、日期-时间戳 转换

日期转时间戳

// var str = "2018-06-08 18:00:00"
// var time = new Date(str.split(" ")).gettime();

// 转十位 时间戳
export function toTimeStamp(date) {
    return new Date(date.split(" ")).getTime()/1000
}

// 转十三位 时间戳
export function toTimeStamp(date) {
    return new Date(date.split(" ")).getTime()
}

时间戳转日期

//字符串拼接
function strFormat(str) {
    return str < 10 ? `0${str}` : str
}

//时间戳转日期
export function timeStamp(time, isQuantum) {
    const dates = new Date(time)
    const year = dates.getFullYear()
    const month = dates.getMonth() + 1
    const date = dates.getDate()
    const day = dates.getDay()
    const hour = dates.getHours()
    const min = dates.getMinutes()
    const secon = dates.getSeconds()
    const days = ['日', '一', '二', '三', '四', '五', '六']
    return {
        allDate: `${year}/${strFormat(month)}/${strFormat(date)}`,
        date: `${strFormat(year)}-${strFormat(month)}-${strFormat(date)}`, //返回的日期 07-01
        day: `星期${days[day]}`, //返回的礼拜天数  星期一
        hour: strFormat(hour) + ':' + strFormat(min) + (isQuantum ? "" : ':00'), //返回的时钟 08:00
        times: strFormat(hour) + ':' + strFormat(min) + ':' + strFormat(secon) // 返回 时间 00:00:00
    }
}

六、uniapp 结合微信支付

获取订单号 --- 订单号调微信支付

getDataBackMeans(val){ // 接受时间预约完成跳回参数
                console.log(val)
                const {play_id,time_start,time_end}=val;
                // play_with_pay
                this.$req(api.play_with_pay,{
                    play_id,
                    time_start,
                    time_end
                },'POST').then(res=>{
                    const that = this
                    let dataobj = res.data; //微信小程序的订单数据
                    uni.requestPayment({
                        provider:"wxpay",
                        timeStamp: dataobj.timeStamp,
                        nonceStr: dataobj.nonceStr,
                        package: dataobj.package,
                        signType: dataobj.signType,
                        paySign: dataobj.paySign,
                        success: (ress)=> {
                            uni.showToast({
                                title: '支付成功',
                                duration: 1000
                            })
                            uni.$emit('updateUserCenter')
                            setTimeout(v=>{
                                that.back()
                            },1000)
                        },
                        fail: function(err) {
                            console.log(999,err)
                        }
                    })
                })
                
            },
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值