如何给文章详情和产品详情页添加 一键拨号和返回首页按钮?

来源:未知 浏览 1271次 时间 2021-03-13 13:50

A.增添界面款式:复制以下整段代码分别放在info_article.swan(文章确定页)和info_product.swan(产品确定页)结果空白地位。

<button bindtap="calling">电话接洽</button>

<view >

<navigator open-type="switchTab" url="/pages/index/index"  hover- >返回顾页</navigator>

</view>

B.增添JS函数:分别复制以下代码到info_article.js(文章确定页)和info_product.js(产品确定页),放在结果一个})前方,已经有该js函数的无需反复增添。注沉标点,

,calling: function (e) {

        let mobile = e.currentTarget.dataset.id;

        if (!mobile) {

            mobile = app.globaldata.settings.cfg_kefu_tel;

        }

        swan.makePhoneCall({

            phoneNumber: mobile,

            success: function () {

                console.log("拨挨电话成功!")

            },

            fail: function () {

                console.log("拨挨电话波折!")

            }

        })

    }

0.png

标签: gtltmobile确定