“最难不过坚持”
本人承接扒站仿站,php网站维护,病毒查杀,网站编辑,网站改版,html制作
有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339
- https://jueru.net/
-
评 留言
- :weixiao:
-
评 留言
- :shuijiao: :weiqu: :zhenbang: :leng:
-
评 留言
- :yiwen: :yiwen: :yiwen: :yiwen:
-
评 EasySass: could not generate CSS file. See Output panel for details.
- 这个业务逻辑多少都有点奇怪了,阅读浏览次数增值在新闻详情页的控制器方法里setInc,这怎么还写进模型事件里了。如果非要用onAfterRead也可以,把新闻文章的内容单独分出来一个news_content表,然后把它和news做关联,然后给news_content表的onAfterRead事件做增值处理,这样点进新闻页内查询到文章内容时才会触发它。
-
评 TP6模型事件-查询后onAfterRead不好用
短信跳转微信小程序
1,官方文档
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/staticstorage/msg-miniprogram.html
2,下载资源包
解压后
3,h5里面,是静态网站的html文档,打开之后
叫jump-mp.html或者改成index.html都行,配置静态网站,索引文件时,名称对应就行。
4,打开jump-mp.html文件
把里面标记<!-- replace -->的地方,替换成自己小程序的信息,共7处
5,打开cloudfunctions\public\index.js,把里面标记<!-- replace -->的地方,改成自己小程序的页面,不填写默认小程序首页,共1处
6,打开微信开发者工具,
随便创建一个小程序,添加自己小程序的appid,选择云开发
7,进去之后,把下载的cloudfunctions文件夹,粘贴到小程序的根目录,然后在public文件夹上,右键》创建并部署(不上传node-modules)
成功上传后,public前面的图标会变成绿色
8,点击顶部“云开发”按钮
9,开通静态网站(前提是你一级开通了云开发环境)
10,点击【更多》静态网站】,文件管理》上传文件,上传下载的并修改成自己信息的jump-mp.html或者index.html文件
网站配置,索引文件,改成你自己的文件名称,jump-mp.html或者index.html
11,点击【设置》权限设置】,把“未登录用户访问权限”打开
12,点击【云函数》云函数权限】,自定义安全规则》修改,点击“允许所有用户访问”,点击确定
13,然后就是在自己的管理后台,通过接口发送短信了。
thinkphp发送代码:
/**
* 发短信-微信小程序短信,自定义发送内容,携带url地址,可以点击短信打开微信小程序
* 贵,且延迟收到短信,大概15分钟
* 手机号码前比较加'+86'
*/
public function sendMessage(){
$id = $this->request->post('id');
if ($id && $id != '') {
$PersonModel = new PersonModel();
$person = $PersonModel->where(['id' => $id])->find();
if($person){
if($person['parentTel'] != ''){
$phones = ['+86'.$person['parentTel']];
$content = "尊敬的".$person['name']."同学:您的眼部检测报告已经完成";
$rs = $this->sendSms($phones,$content); // 支持批量发送
if($rs['errcode'] == 0){
$this->code(200, 'sendMessageSuccess');
}else{
$this->code(403, 'sendMessageFailed');
}
} else {
$this->code(403, 'sendMessageFailed');
}
}else{
$this->code(403, 'sendMessageFailed');
}
}
}
/**
* 微信小程序云开发发送短信
*/
public function sendSms($phones,$content){
$access_token=$this->gettoken();
$qcode ="https://api.weixin.qq.com/tcb/sendsms?access_token=$access_token";
$param = json_encode(array(
"env"=>"duanxin-0g123412341234",
"phone_number_list"=>$phones,
// "phone_number_list"=>[
// "+8615012341234","+8615012341234","+8615012341234"
// ],
"sms_type"=> "Marketing",
"content"=>$content,
"path"=>"/index.html",
"use_short_name"=> true
),JSON_UNESCAPED_UNICODE);
// $param = json_encode(array(
// "env"=>"duanxin-0g123412341234",
// "phone_number_list"=>[
// "+8615012341234","+8615012341234"
// ],
// "sms_type"=>"Notification",
// "template_id"=>"844110",
// "template_param_list"=>["商品", "/index.html"]
// ),JSON_UNESCAPED_UNICODE);
//POST参数
$res = $this->httpRequest($qcode,$param,"POST");
$res = json_decode($res, true);
return $res;
}
/**
* 获取微信小程序access_token
*/
public function gettoken(){
$WechatModel = new WechatModel();
$appinfo = $WechatModel->where('id',1)->find();
$appid = $appinfo['appid'];
$time=time();
if($time>=$appinfo['gettokentime']+7200){
$appsecret = $appinfo['appsecret'];
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
$info=$this->httpRequest($url);
$data = json_decode($info, true);
$appinfo['id']=1;
$appinfo['gettokentime']=$time;
$appinfo['accesstoken']=$data['access_token'];
$appinfo->save($appinfo);
return $data['access_token'];
}else{
return $appinfo['accesstoken'];
}
}
public function httpRequest($url, $data='', $method='GET'){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
if($method=='POST')
{
curl_setopt($curl, CURLOPT_POST, 1);
if ($data != '')
{
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
14,前往「微信开发者工具-云开发控制台-设置-环境设置-目标环境-资源包」中购买短信资源包。说是有100条免费短信,但是发了一条或者0条,就提示余额不足了,买了50元1000条。
15,短信样式:【小程序名称】自定义内容,跳转小程序 https://tcbe.cn/asdsdyZ 回T退订
16,短信发送成功,但是手机短信没有收到,可能是被拦截了,短信》通知信息》更多》骚扰拦截,里面如果有拦截的信息,可以加入白名单,放出来。
如果同一个手机号,反复试验,发送同样的短信,运营商也会拦截,这样就发送失败了,手机不会收到