addtable.inc.php
2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getMainMenu2();
$storeid=$_COOKIE["storeid"];
$cur_store = $this->getStoreById($storeid);
function getCoade($table_id,$storeid){
function getaccess_token(){
global $_W, $_GPC;
$res=pdo_get('cjdc_system',array('uniacid' => $_W['uniacid']));
$appid=$res['appid'];
$secret=$res['appsecret'];
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret."";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$data = curl_exec($ch);
curl_close($ch);
$data = json_decode($data,true);
return $data['access_token'];
}
function set_msg($table_id,$storeid){
$access_token = getaccess_token();
$data2=array(
"scene"=>$table_id.",".$storeid,
"page"=>"zh_cjdianc/pages/smdc/smdcindex",
"width"=>400
);
$data2 = json_encode($data2);
$url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$access_token."";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data2);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$img=set_msg($table_id,$storeid);
$img=base64_encode($img);
return $img;
}
if(!$_GPC['id']==''){
$img=getCoade($_GPC['id'],$storeid);
}
$list = pdo_get('cjdc_table',array('uniacid' => $_W['uniacid'],'id'=>$_GPC['id']));
$type = pdo_getall('cjdc_table_type',array('uniacid' => $_W['uniacid'],'store_id'=>$storeid));
if(checksubmit('submit')){
$data['name']=$_GPC['name'];
$data['num']=$_GPC['num'];
$data['type_id']=$_GPC['type_id'];
$data['tag']=$_GPC['tag'];
$data['uniacid']=$_W['uniacid'];
$data['store_id']=$storeid;
$data['orderby']=$_GPC['orderby'];
if($_GPC['id']==''){
$data['status']=0;
$res=pdo_insert('cjdc_table',$data);
if($res){
message('添加成功',$this->createWebUrl('table',array()),'success');
}else{
message('添加失败','','error');
}
}else{
$res = pdo_update('cjdc_table', $data, array('id' => $_GPC['id']));
if($res){
message('编辑成功',$this->createWebUrl('table',array()),'success');
}else{
message('编辑失败','','error');
}
}
}
include $this->template('web/addtable');