作者 李涵

合并分支 'li' 到 'master'

渲染



查看合并请求 !5
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: yhbr
  5 + * Date: 2018/9/28
  6 + * Time: 16:12
  7 + */
  8 +namespace app\cart\controller;
  9 +use app\cart\model\CartModel;
  10 +use cmf\controller\HomeBaseController;
  11 +
  12 +class CartController extends HomeBaseController
  13 +{
  14 +
  15 + public function addCart()
  16 + {
  17 + $cart = new CartModel;
  18 + $request = request();
  19 + if ($request->isAjax()) {
  20 + $gid = $request->param('gid');
  21 + $num = $request->param('num');
  22 + $cart->addToCart(session('user.id', $gid, $num));
  23 + }
  24 + }
  25 +
  26 + public function editCart()
  27 + {
  28 + $request = request();
  29 + if ($request->isAjax()) {
  30 + $cart = [
  31 + 'id' => $request->param('id'),
  32 + 'num' => $request->param('num')
  33 + ];
  34 + Db::name('cart')->update($cart);
  35 + }
  36 + }
  37 +
  38 + public function delCart()
  39 + {
  40 + $request = request();
  41 + if ($request->isAjax()) {
  42 + if (Db::name('cart')->delete($request->param('id'))) {
  43 + $this->success('', '', true);
  44 + }
  45 + }
  46 + }
  47 +
  48 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: yhbr
  5 + * Date: 2018/9/28
  6 + * Time: 15:36
  7 + */
  8 +
  9 +namespace app\cart\model;
  10 +use think\Model;
  11 +use think\Db;
  12 +
  13 +class CartModel extends Model
  14 +{
  15 +
  16 + public function addToCart($uid, $gid, $num)
  17 + {
  18 + if ($this->checkIsExist($uid, $gid)) {
  19 + $cart = [
  20 + 'uid' => $uid,
  21 + 'gid' => $gid,
  22 + 'num' => $num
  23 + ];
  24 + if (Db::name('zj_cart')->insert($cart)) {
  25 + return true;
  26 + } else {
  27 + return false;
  28 + }
  29 + } else {
  30 + $map = [
  31 + 'uid' => $uid,
  32 + 'gid' => $gid
  33 + ];
  34 + if (Db::name('zj_cart')->where($map)->setInc('num', $num)) {
  35 + return true;
  36 + } else {
  37 + return false;
  38 + }
  39 + }
  40 + }
  41 +
  42 + private function checkIsExist($uid, $gid)
  43 + {
  44 + return (Db::name('zj_cart')->where(['uid' => $uid, 'gid' => $gid])->count() == 0) ? true : false;
  45 + }
  46 +
  47 +}
@@ -7,6 +7,12 @@ use think\Db; @@ -7,6 +7,12 @@ use think\Db;
7 class IndexController extends HomeBaseController 7 class IndexController extends HomeBaseController
8 { 8 {
9 9
  10 + function _initialize()
  11 + {
  12 + parent::_initialize(); // TODO: Change the autogenerated stub
  13 + session('user.id', 8);
  14 + }
  15 +
10 public function index() 16 public function index()
11 { 17 {
12 $goods = new GoodsModel; 18 $goods = new GoodsModel;
@@ -20,4 +26,22 @@ class IndexController extends HomeBaseController @@ -20,4 +26,22 @@ class IndexController extends HomeBaseController
20 ]); 26 ]);
21 } 27 }
22 28
  29 + /**
  30 + * 易连云打印机demo
  31 + */
  32 + public function demo()
  33 + {
  34 + //调用打印机
  35 + //1.配置信息
  36 + $config = [
  37 + 'partner' => '27606',
  38 + 'machine_code' => '4004564414',
  39 + 'apiKey' => '1580c3fc2adca994e18b0982b42af850518011d0',
  40 + 'msign' => '6kdjyzsr4sf3'
  41 + ];
  42 + //2.打印内容(以一行三列的表格为例,内容不允许出现回车换行,切记!)
  43 + $content = '<table><tr><td>银河百荣科技</td><td>demo</td><td>By Soul of Cinder</td></tr></table>';
  44 + printer($config, $content);
  45 + }
  46 +
23 } 47 }
@@ -93,16 +93,94 @@ class CenterController extends HomeBaseController @@ -93,16 +93,94 @@ class CenterController extends HomeBaseController
93 /** 93 /**
94 * 地址管理 94 * 地址管理
95 */ 95 */
96 - public function addressManage() { 96 + public function addressManage()
  97 + {
97 $address = Db::name('zj_user_place') 98 $address = Db::name('zj_user_place')
98 - ->field('id,name,province,city,county,mobile,is_sta')  
99 - ->where(['uid'=>session('user.id')]) 99 + ->field('id,name,province,city,county,mobile,is_sta,place')
  100 + ->where(['uid' => session('user.id')])
100 ->select() 101 ->select()
101 ->toArray(); 102 ->toArray();
102 - print_r($address);exit();  
103 return $this->fetch('address_manage', [ 103 return $this->fetch('address_manage', [
104 'data' => $address 104 'data' => $address
105 ]); 105 ]);
106 } 106 }
107 107
  108 + public function addAddress()
  109 + {
  110 + $request = request();
  111 + if ($request->isAjax()) {
  112 + $post = $request->param();
  113 + $code = $post['code'];
  114 + $label = $post['label'];
  115 + $arr1 = explode(',', $code);
  116 + $post['province_id'] = $arr1[0];
  117 + $post['city_id'] = $arr1[1];
  118 + $post['county_id'] = $arr1[2];
  119 + $arr2 = explode(' ', $label);
  120 + $post['province'] = $arr2[0];
  121 + $post['city'] = $arr2[1];
  122 + $post['county'] = $arr2[2];
  123 + unset($post['code']);
  124 + unset($post['label']);
  125 + $post['uid'] = session('user.id');
  126 + if (Db::name('zj_user_place')->insert($post)) {
  127 + $this->success('', url('user/Center/addressManage'), true);
  128 + }
  129 +
  130 + } else {
  131 + return $this->fetch('add_address');
  132 + }
  133 + }
  134 +
  135 + public function delAddress()
  136 + {
  137 + if (Db::name('zj_user_place')->delete(request()->param('id'))) {
  138 + $this->success('', '', true);
  139 + }
  140 + }
  141 +
  142 + public function editAddress()
  143 + {
  144 + $request = request();
  145 + if ($request->isAjax()) {
  146 + $post = $request->param();
  147 + $code = $post['code'];
  148 + $label = $post['label'];
  149 + $arr1 = explode(',', $code);
  150 + $post['province_id'] = $arr1[0];
  151 + $post['city_id'] = $arr1[1];
  152 + $post['county_id'] = $arr1[2];
  153 + $arr2 = explode(' ', $label);
  154 + $post['province'] = $arr2[0];
  155 + $post['city'] = $arr2[1];
  156 + $post['county'] = $arr2[2];
  157 + unset($post['code']);
  158 + unset($post['label']);
  159 + $post['uid'] = session('user.id');
  160 + if (Db::name('zj_user_place')->update($post)) {
  161 + $this->success('', url('user/Center/addressManage'), true);
  162 + }
  163 + } else {
  164 + return $this->fetch('edit_address', [
  165 + 'data' => Db::name('zj_user_place')
  166 + ->field('id,name,mobile,place,province_id,city_id,county_id,province,city,county')
  167 + ->where(['id' => $request->param('id')])
  168 + ->find()
  169 + ]);
  170 + }
  171 + }
  172 +
  173 + public function setDefault()
  174 + {
  175 + Db::name('zj_user_place')->where(['uid' => session('user.id')])->update(['is_sta' => 1]);
  176 + Db::name('zj_user_place')->where(['id' => request()->param('id')])->update(['is_sta' => request()->param('is_sta')]);
  177 + }
  178 +
  179 + public function myBalance()
  180 + {
  181 + return $this->fetch('my_balance', [
  182 + 'balance' => Db::name('user')->where(['id' => session('user.id')])->value('balance')
  183 + ]);
  184 + }
  185 +
108 } 186 }
@@ -112,8 +112,8 @@ body,html{ @@ -112,8 +112,8 @@ body,html{
112 .goodreason{ 112 .goodreason{
113 font-size: 0.26rem; 113 font-size: 0.26rem;
114 color:RGBA(26, 26, 26, 1); 114 color:RGBA(26, 26, 26, 1);
115 - margin-top: 0.73rem;  
116 - height:1.4rem; 115 + margin-top: 0.18rem;
  116 + height:1.8rem;
117 overflow: auto; 117 overflow: auto;
118 } 118 }
119 .phone{ 119 .phone{
@@ -57,18 +57,18 @@ body,html{ @@ -57,18 +57,18 @@ body,html{
57 .cart_tast{ 57 .cart_tast{
58 color: #666666; 58 color: #666666;
59 font-size: 0.26rem; 59 font-size: 0.26rem;
60 - margin-top: 0.12rem; 60 + margin-top: 0.1rem;
61 } 61 }
62 .inter{ 62 .inter{
63 color:#FF0000; 63 color:#FF0000;
64 font-size: 0.24rem; 64 font-size: 0.24rem;
65 - margin-top: 0.17rem; 65 + margin-top: 0.1rem;
66 } 66 }
67 .addcart{ 67 .addcart{
68 display:flex; 68 display:flex;
69 justify-content: space-between; 69 justify-content: space-between;
70 align-items: center; 70 align-items: center;
71 - margin-top: 0.08rem; 71 + margin-top: 0.03rem;
72 height:0.5rem; 72 height:0.5rem;
73 73
74 } 74 }
@@ -64,14 +64,16 @@ body,html{ @@ -64,14 +64,16 @@ body,html{
64 .text_img{ 64 .text_img{
65 width:1.2rem; 65 width:1.2rem;
66 height:1.2rem; 66 height:1.2rem;
  67 + border-radius: 0.1rem;
67 } 68 }
68 .container_list{ 69 .container_list{
69 display:flex; 70 display:flex;
70 - border-bottom: 0.01rem solid #EBEBEB; 71 + border-bottom: 1px solid #f5f5f5;
71 padding:0.23rem 0; 72 padding:0.23rem 0;
72 } 73 }
73 .text_img img{ 74 .text_img img{
74 width:100%; 75 width:100%;
  76 + border-radius: 0.1rem;
75 } 77 }
76 .container_info{ 78 .container_info{
77 margin-left: 0.24rem; 79 margin-left: 0.24rem;
@@ -98,7 +100,7 @@ body,html{ @@ -98,7 +100,7 @@ body,html{
98 display:flex; 100 display:flex;
99 justify-content: space-between; 101 justify-content: space-between;
100 align-items: center; 102 align-items: center;
101 - margin-top: 0.1rem; 103 + margin-top: 0.03rem;
102 } 104 }
103 .people_weight{ 105 .people_weight{
104 width:2rem; 106 width:2rem;
@@ -40,8 +40,9 @@ body,html{ @@ -40,8 +40,9 @@ body,html{
40 .list_name{ 40 .list_name{
41 color:RGBA(83, 87, 92, 1); 41 color:RGBA(83, 87, 92, 1);
42 font-size: 0.28rem; 42 font-size: 0.28rem;
43 - height:0.26rem; 43 + /*height:0.5rem;*/
44 line-height: 0.26rem; 44 line-height: 0.26rem;
  45 +
45 } 46 }
46 .item{ 47 .item{
47 margin-top: 0.16rem; 48 margin-top: 0.16rem;
@@ -58,6 +58,8 @@ body,html{ @@ -58,6 +58,8 @@ body,html{
58 .good_content{ 58 .good_content{
59 /*width:4.56rem;*/ 59 /*width:4.56rem;*/
60 height:1rem; 60 height:1rem;
  61 + line-height: 1rem;
  62 + border-bottom: 1px solid #f5f5f5;
61 display:flex; 63 display:flex;
62 justify-content: space-between; 64 justify-content: space-between;
63 align-items: center; 65 align-items: center;
@@ -76,7 +78,7 @@ body,html{ @@ -76,7 +78,7 @@ body,html{
76 } 78 }
77 .good_content .active em{ 79 .good_content .active em{
78 position: absolute; 80 position: absolute;
79 - top:0.45rem; 81 + top:0.75rem;
80 left:0; 82 left:0;
81 right:0; 83 right:0;
82 width:0.8rem; 84 width:0.8rem;
@@ -97,6 +99,7 @@ body,html{ @@ -97,6 +99,7 @@ body,html{
97 height:0.25rem; 99 height:0.25rem;
98 text-align: center; 100 text-align: center;
99 margin: 0 auto; 101 margin: 0 auto;
  102 + margin-top: 0.2rem;
100 } 103 }
101 .good_info_img{ 104 .good_info_img{
102 width:7.5rem; 105 width:7.5rem;
@@ -61,7 +61,8 @@ body,html{ @@ -61,7 +61,8 @@ body,html{
61 } 61 }
62 .specialword p{ 62 .specialword p{
63 width:1.2rem; 63 width:1.2rem;
64 - height:1.2rem; 64 + text-align: center;
  65 + height:0.8rem;
65 font-size:0.28rem ; 66 font-size:0.28rem ;
66 color:#666666; 67 color:#666666;
67 margin-top: 0.2rem; 68 margin-top: 0.2rem;
@@ -183,6 +184,7 @@ body,html{ @@ -183,6 +184,7 @@ body,html{
183 left:0; 184 left:0;
184 right:0; 185 right:0;
185 background: #fff; 186 background: #fff;
  187 + border-top:1px solid #f5f5f5;
186 188
187 189
188 } 190 }
@@ -75,8 +75,8 @@ li.active { @@ -75,8 +75,8 @@ li.active {
75 margin-top:0; 75 margin-top:0;
76 } 76 }
77 .order_content{ 77 .order_content{
78 - background:RGBA(250, 250, 250, 1) ;  
79 - padding: 0.18rem; 78 + /*background:RGBA(250, 250, 250, 1) ;*/
  79 + padding:0.18rem 0;
80 } 80 }
81 .content_text{ 81 .content_text{
82 margin-left: 0.3rem; 82 margin-left: 0.3rem;
@@ -94,7 +94,7 @@ li.active { @@ -94,7 +94,7 @@ li.active {
94 color:#FE0A01; 94 color:#FE0A01;
95 } 95 }
96 .good_name{ 96 .good_name{
97 - width:4.5rem; 97 + width:4.9rem;
98 98
99 color:#1A1A1A; 99 color:#1A1A1A;
100 font-size: 0.26rem; 100 font-size: 0.26rem;
@@ -107,7 +107,7 @@ li.active { @@ -107,7 +107,7 @@ li.active {
107 display:flex; 107 display:flex;
108 justify-content: space-between; 108 justify-content: space-between;
109 align-items: center; 109 align-items: center;
110 - margin-top:0.16rem; 110 + margin-top:0.1rem;
111 } 111 }
112 .item_tast,.tast_num{ 112 .item_tast,.tast_num{
113 font-size: 0.26rem; 113 font-size: 0.26rem;
@@ -20,11 +20,15 @@ body,html{ @@ -20,11 +20,15 @@ body,html{
20 .people_name{ 20 .people_name{
21 color:#1A1A1A; 21 color:#1A1A1A;
22 font-size: 0.26rem; 22 font-size: 0.26rem;
  23 + height:0.2rem;
  24 + line-height: 0.2rem;
23 } 25 }
24 .people_phone{ 26 .people_phone{
25 color:#1A1A1A; 27 color:#1A1A1A;
26 font-size: 0.26rem; 28 font-size: 0.26rem;
27 margin-left: 0.27rem; 29 margin-left: 0.27rem;
  30 + height:0.2rem;
  31 + line-height: 0.2rem;
28 } 32 }
29 .people_place { 33 .people_place {
30 font-size: 0.26rem; 34 font-size: 0.26rem;
@@ -61,10 +65,13 @@ body,html{ @@ -61,10 +65,13 @@ body,html{
61 .order_img{ 65 .order_img{
62 width:1.28rem; 66 width:1.28rem;
63 height:1.28rem; 67 height:1.28rem;
  68 + border-radius: 0.1rem;
  69 +
64 } 70 }
65 71
66 .order_img img{ 72 .order_img img{
67 width:100%; 73 width:100%;
  74 + border-radius: 0.1rem;
68 } 75 }
69 .good_list{ 76 .good_list{
70 width:4.5rem; 77 width:4.5rem;
@@ -118,7 +125,7 @@ body,html{ @@ -118,7 +125,7 @@ body,html{
118 } 125 }
119 /*购买数量*/ 126 /*购买数量*/
120 .dispatch{ 127 .dispatch{
121 - width:6.68rem; 128 + width:6.86rem;
122 height:1.92rem; 129 height:1.92rem;
123 margin: 0 auto; 130 margin: 0 auto;
124 background: #fff; 131 background: #fff;
@@ -306,7 +313,8 @@ body,html{ @@ -306,7 +313,8 @@ body,html{
306 } 313 }
307 .buy_order_money{ 314 .buy_order_money{
308 width:4.6rem; 315 width:4.6rem;
309 - 316 + height:0.3rem;
  317 + line-height: 0.3rem;
310 display:flex; 318 display:flex;
311 justify-content:space-between; 319 justify-content:space-between;
312 align-items: center; 320 align-items: center;
@@ -325,6 +333,8 @@ body,html{ @@ -325,6 +333,8 @@ body,html{
325 } 333 }
326 334
327 .buyorder,.ordermoney{ 335 .buyorder,.ordermoney{
  336 + height:0.3rem;
  337 + line-height: 0.3rem;
328 color:#1A1A1A; 338 color:#1A1A1A;
329 font-size: 0.28rem; 339 font-size: 0.28rem;
330 } 340 }
@@ -226,7 +226,7 @@ @@ -226,7 +226,7 @@
226 } 226 }
227 227
228 .swiper-container-horizontal>.swiper-pagination-bullets,.swiper-pagination-custom,.swiper-pagination-fraction { 228 .swiper-container-horizontal>.swiper-pagination-bullets,.swiper-pagination-custom,.swiper-pagination-fraction {
229 - bottom: 10px; 229 + bottom: -5px;
230 left: 0; 230 left: 0;
231 width: 100% 231 width: 100%
232 } 232 }
  1 +
  2 +<!DOCTYPE html>
  3 +<html lang="en">
  4 +<head>
  5 + <meta charset="UTF-8">
  6 + <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7 + <link rel="stylesheet" href="__INDEX__/css/weui.css">
  8 + <link rel="stylesheet" href="__INDEX__/css/jquery-weui.css">
  9 + <link rel="stylesheet" href="__INDEX__/css/demos.css">
  10 + <link rel="stylesheet" href="https://at.alicdn.com/t/font_834805_9njxvxqweig.css">
  11 + <link rel="stylesheet" href="__INDEX__/css/base.css">
  12 + <link rel="stylesheet" href="__INDEX__/css/swiper.min.css">
  13 + <script type="text/javascript" src="__INDEX__/js/base.js"></script>
  14 + <title>添加地址</title>
  15 + <style>
  16 + body,html{
  17 + width:100%;
  18 + height:100%;
  19 + background: #F5F6FA;
  20 + }
  21 + .select_address{
  22 + width:6.86rem;
  23 + margin: 0 auto;
  24 + height:1.01rem;
  25 + border-bottom: 1px solid #f5f5f5;
  26 + display:flex;
  27 + /*justify-content: space-between;*/
  28 + align-items: center;
  29 + position: relative;
  30 + padding: 0 0.33rem;
  31 +
  32 + }
  33 + .weui-cell{
  34 + /*display:flex;*/
  35 + /*justify-content: space-between;*/
  36 + /*align-items: center;*/
  37 + }
  38 + .detail_address{
  39 + width:6.86rem;
  40 + margin: 0 auto;
  41 + height:1.01rem;
  42 + border-bottom: 1px solid #f5f5f5;
  43 + display:flex;
  44 + /*justify-content: space-between;*/
  45 + align-items: center;
  46 + padding: 0 0.33rem;
  47 + }
  48 + .place{
  49 + width:1.5rem;
  50 + color:#1A1A1A;
  51 + font-size: 0.3rem;
  52 + }
  53 + .detailplace{
  54 + color:#999999;
  55 + font-size: 0.3rem;
  56 + }
  57 + .province{
  58 + color:#999999;
  59 + font-size: 0.3rem;
  60 + }
  61 + .weui-label {
  62 + width:1.3rem;
  63 + }
  64 + .detailplace{
  65 + border:none;
  66 + outline: none;
  67 + /*margin-right:0.6rem;*/
  68 + }
  69 + .select{
  70 + background: #fff;
  71 + }
  72 + .save{
  73 + width:6.86rem;
  74 + height:0.88rem;
  75 + background:#FE0A01;
  76 + color:#fff;
  77 + font-size:0.32rem ;
  78 + text-align: center;
  79 + line-height: 0.88rem;
  80 + border-radius: 0.44rem;
  81 + position:fixed;
  82 + bottom:0.55rem;
  83 + left:0;
  84 + right:0;
  85 + margin: 0 auto;
  86 + box-shadow:0px 15px 30px 0px rgba(254,10,1,0.24);
  87 + }
  88 + .icon-xiaotuziCduan_{
  89 + color:#999999;
  90 + font-size: 0.5rem;
  91 + position:absolute;
  92 + right:0.3rem;
  93 + z-index: 5;
  94 + }
  95 + .selectadd{
  96 + width:4.6rem;
  97 + position:relative;
  98 + border:none;
  99 + outline:none;
  100 + z-index: 8;
  101 + /*margin-left: 0.5rem;*/
  102 + }
  103 + </style>
  104 +</head>
  105 +<body>
  106 +<div class="container">
  107 + <div class="select">
  108 + <div class="select_address">
  109 + <p class="place">选择地区</p>
  110 + <div class="weui-cell" style="padding: 0">
  111 + <!--<div class="weui-cell__hd"><label for="date" class="weui-label place">选择地区</label></div>-->
  112 + <div class="weui-cell__bd">
  113 + <input class="weui-input selectadd" id="end" type="text" placeholder="请选择省市区" >
  114 + </div>
  115 + </div>
  116 + <p class="iconfont icon-xiaotuziCduan_"></p>
  117 + </div>
  118 + <div class="detail_address">
  119 + <p class="place">详细地址</p>
  120 + <input id="P" type="text" placeholder="请填写详细地址" class="detailplace">
  121 + </div>
  122 + <div class="detail_address">
  123 + <p class="place">收货人</p>
  124 + <input id="N" type="text" placeholder="请填写收货人" class="detailplace">
  125 + </div>
  126 + <div class="detail_address">
  127 + <p class="place">联系电话</p>
  128 + <input id="M" type="text" placeholder="请填写联系电话" class="detailplace">
  129 + </div>
  130 + </div>
  131 + <div class="save">保存</div>
  132 +</div>
  133 +</body>
  134 +<script type="text/javascript" src="__INDEX__/js/jquery-2.1.4.js"></script>
  135 +<script type="text/javascript" src="__INDEX__/js/fastclick.js"></script>
  136 +<script>
  137 + $(function() {
  138 + FastClick.attach(document.body);
  139 + });
  140 +</script>
  141 +<script type="text/javascript" src="__INDEX__/js/jquery-weui.js"></script>
  142 +<script type="text/javascript" src="__INDEX__/js/city-picker.js"></script>
  143 +
  144 +<script>
  145 + $("#end,.icon-xiaotuziCduan").cityPicker({
  146 + title: "请选择地区"
  147 + });
  148 +</script>
  149 +
  150 +<script>
  151 + $(".save").click(function () {
  152 + var code = $("#end").attr('data-codes');
  153 + var label = $("#end").val();
  154 + if(code == null || label == null || $("#P").val() == '' || $("#N").val() == '' || $("#M").val() == '') {
  155 + alert('请完善地址信息');
  156 + }else {
  157 + $.ajax({
  158 + url: "{:url('user/Center/addAddress')}",
  159 + data: {
  160 + code: code,
  161 + label: label,
  162 + place: $("#P").val(),
  163 + name: $("#N").val(),
  164 + mobile: $("#M").val()
  165 + },
  166 + type: "POST",
  167 + dataType: "JSON",
  168 +
  169 + success: function (data) {
  170 + window.location.href = data.url;
  171 + }
  172 + })
  173 + }
  174 + })
  175 +</script>
  176 +</html>
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +<head>
  4 + <meta charset="UTF-8">
  5 + <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  6 + <link rel="stylesheet" href="__INDEX__/css/weui.css">
  7 + <link rel="stylesheet" href="__INDEX__/css/jquery-weui.css">
  8 + <link rel="stylesheet" href="__INDEX__/css/demos.css">
  9 + <link rel="stylesheet" href="https://at.alicdn.com/t/font_834805_bx3vyrf79mj.css">
  10 + <link rel="stylesheet" href="__INDEX__/css/base.css">
  11 + <link rel="stylesheet" href="__INDEX__/css/swiper.min.css">
  12 + <script type="text/javascript" src="__INDEX__/js/base.js"></script>
  13 + <title>选择地址</title>
  14 + <style>
  15 + body,html{
  16 + background: RGBA(245, 246, 250, 1);
  17 + }
  18 + .icon-dizhi{
  19 + color:#999999;
  20 + font-size: 0.55rem;
  21 + }
  22 + .manageraddress{
  23 + border-bottom: 1px solid #f5f5f5;
  24 + padding-bottom: 0.41rem;
  25 + padding-top: 0.1rem;
  26 + }
  27 + .addresshead{
  28 + display:flex;
  29 + /*margin-top: 0.38rem;*/
  30 + margin-left: 0.23rem;
  31 + }
  32 + .place{
  33 + width:6rem;
  34 + overflow: hidden;
  35 + text-overflow: ellipsis;
  36 + white-space: nowrap;
  37 + color:#1A1A1A;
  38 + font-size: 0.26rem;
  39 + margin-left: 0.18rem;
  40 + margin-top: 0.2rem;
  41 + }
  42 + .info{
  43 + display:flex;
  44 + margin-left: 0.96rem;
  45 + }
  46 + .name{
  47 + color:#1A1A1A;
  48 + font-size: 0.28rem;
  49 + }
  50 + .telphone{
  51 + color:#1A1A1A;
  52 + font-size: 0.28rem;
  53 + margin-left: 0.59rem;
  54 + }
  55 + .icon-xuanzekuang{
  56 + font-size: 0.28rem;
  57 + color:#999999;
  58 + width:0.32rem;
  59 + text-align: center;
  60 + height:0.28rem;
  61 + line-height: 0.28rem;
  62 + }
  63 + .icon-xuanze-fangkuang{
  64 + width:0.32rem;
  65 + text-align: center;
  66 + font-size: 0.28rem;
  67 + height:0.28rem;
  68 + line-height: 0.28rem;
  69 + color:#FF0800;
  70 + }
  71 + .default_place{
  72 + color:#333333;
  73 + font-size: 0.24rem;
  74 + height:0.28rem;
  75 + line-height: 0.28rem;
  76 + margin-left: 0.11rem;
  77 + }
  78 + .default_body{
  79 + display:flex;
  80 + justify-content: space-between;
  81 + align-items: center;
  82 + padding: 0.26rem 0.32rem 0.26rem 0.8rem;
  83 + }
  84 + .default,.default_type,.edit,.delect{
  85 + display:flex;
  86 + }
  87 + .delect{
  88 + margin-left: 0.54rem;
  89 + }
  90 + .defauledi,.defaultdel{
  91 + color:#666666;
  92 + font-size: 0.24rem;
  93 + height:0.23rem;
  94 + line-height: 0.23rem;
  95 + margin-left: 0.1rem;
  96 + }
  97 + .icon-bianji,.icon-shanchu{
  98 + height:0.23rem;
  99 + line-height: 0.23rem;
  100 + }
  101 + .default_list{
  102 + background: #fff;
  103 + margin-top: 0.16rem;
  104 +
  105 + }
  106 + .default_list:first-child{
  107 + margin-top: 0;
  108 + }
  109 + .addplace{
  110 + width:7.5rem;
  111 + height:1rem;
  112 + background: RGBA(254, 10, 1, 1);
  113 + color:#fff;
  114 + font-size: 0.36rem;
  115 + text-align: center;
  116 + line-height: 1rem;
  117 + position:fixed;
  118 + bottom:0;
  119 + left:0;
  120 + right:0
  121 +
  122 + }
  123 + .managerplace{
  124 + padding-bottom:1.3rem;
  125 + }
  126 +
  127 +
  128 +
  129 + .add_address{
  130 + color:#999999;
  131 + font-size: 0.36rem;
  132 + margin: 0.32rem 2.31rem 0 2.31rem;
  133 + }
  134 + .addressplus{
  135 + width:2.8rem;
  136 + height:0.8rem;
  137 + border:2px solid rgba(186,27,43,1);
  138 + border-radius:0.05rem;
  139 + color:#BA1B2B;
  140 + font-size: 0.32rem;
  141 + text-align: center;
  142 + line-height: 0.8rem;
  143 + margin: 0.28rem 2.34rem 0 2.34rem;
  144 + }
  145 + .deletewrapper{
  146 + width: 100%;
  147 + height: 100%;
  148 + background-color: rgba(0,0,0,0.5);
  149 + position:fixed;
  150 + top:0;
  151 + left:0;
  152 + right:0;
  153 + z-index: 5;
  154 + }
  155 + .deletepop{
  156 + width:5.2rem;
  157 + height:3rem;
  158 + background: #ffffff;
  159 + border-radius: 0.1rem;
  160 + position: absolute;
  161 + z-index: 6;
  162 + /*left:0.4rem;*/
  163 + /*top: 3rem;*/
  164 + top:50%;
  165 + left:50%;
  166 + transform: translate(-50%,-50%);
  167 + display: flex;
  168 + flex-direction: column;
  169 + align-items: center;
  170 + overflow: hidden;
  171 + padding-top: 0.29rem;
  172 +
  173 + }
  174 + .suredelete{
  175 + color:#1A1A1A;
  176 + font-size: 0.32rem;
  177 + }
  178 + .certainornot{
  179 + font-size: 0.3rem;
  180 + color:#666666;
  181 + margin-top: 0.43rem;
  182 + }
  183 + .certain{
  184 + display:flex;
  185 + justify-content:space-between;
  186 + align-items: center;
  187 + border-top:1px solid #f5f5f5;
  188 + margin-top: 0.4rem;
  189 +
  190 + }
  191 + .cancel,.sure{
  192 + width:2.6rem;
  193 + height:0.88rem;
  194 + line-height: 0.88rem;
  195 + color:#666666;
  196 + font-size: 0.3rem;
  197 + text-align: center;
  198 + }
  199 + .sure{
  200 + color:#FF0000;
  201 + }
  202 + .address_img{
  203 + width:3.2rem;
  204 + height:2.52rem;
  205 + margin: 0 auto;
  206 + margin-top: 3.06rem;
  207 + }
  208 + .address_img img{
  209 + width:100%;
  210 + }
  211 + </style>
  212 +</head>
  213 +<body>
  214 +<div class="deletewrapper" style="display:none">
  215 + <div class="deletepop">
  216 + <p class="suredelete">确认删除</p>
  217 + <p class="certainornot">确定删除该地址吗?</p>
  218 + <div class="certain">
  219 + <p class="cancel">取消</p>
  220 + <p class="sure">确认</p>
  221 + </div>
  222 + </div>
  223 +</div>
  224 +<div class="container">
  225 + <div class="noplace" style="display:none" >
  226 + <div class="address_img">
  227 + <img src="__INDEX__/img/searchaddress.png" alt="">
  228 + </div>
  229 + <p class="add_address">您还没有添加地址</p>
  230 + <div class="addressplus">添加地址</div>
  231 + </div>
  232 + <div class="haveplace" >
  233 + <div class="managerplace">
  234 + <volist name="data" id="vo">
  235 + <div class="default_list">
  236 + <div class="manageraddress">
  237 + <div class="addresshead">
  238 + <p class="iconfont icon-dizhi"></p>
  239 + <p class="place">{$vo.province}{$vo.city}{$vo.county}{$vo.place}</p>
  240 + </div>
  241 + <div class="info">
  242 + <p class="name">{$vo.name}</p>
  243 + <p class="telphone">{$vo.mobile}</p>
  244 + </div>
  245 + </div>
  246 + <div class="default_body">
  247 + <div class="default">
  248 + <if condition="$vo['is_sta'] eq '1'">
  249 + <p data-id="{$vo.id}" data-var="2" class="iconfont icon-xuanzekuang xuan" style="display: block"></p>
  250 + <p data-id="{$vo.id}" data-var="1" class="iconfont icon-xuanze-fangkuang" style="display:none"></p>
  251 + <else/>
  252 + <p data-id="{$vo.id}" data-var="1" class="iconfont icon-xuanzekuang xuan" style="display: none"></p>
  253 + <p data-id="{$vo.id}" data-var="2" class="iconfont icon-xuanze-fangkuang" style="display:block"></p>
  254 + </if>
  255 + <p class="default_place">默认地址</p>
  256 + </div>
  257 + <div class="default_type">
  258 + <div class="edit" data-url="{:url('user/center/editAddress',['id'=>$vo['id']])}">
  259 + <p class="iconfont icon-bianji"></p>
  260 + <p class="defauledi">编辑</p>
  261 + </div>
  262 + <div class="delect">
  263 + <p class="iconfont icon-shanchu"></p>
  264 + <p class="defaultdel" data-id="{$vo.id}">删除</p>
  265 + </div>
  266 + </div>
  267 + </div>
  268 + </div>
  269 + </volist>
  270 + </div>
  271 +
  272 + <div class="addplace">新增收货地址</div>
  273 + </div>
  274 +
  275 +</div>
  276 +<script src="__INDEX__/js/jquery.min.js"></script>
  277 +<script>
  278 + var id='';
  279 + //没有收获地址时候新增收获地址
  280 + $(".addressplus").click(function(){
  281 + window.location.href="{:url('user/Center/addAddress')}";
  282 + })
  283 + //有收获地址的时候新增收获地址
  284 + $(".addplace").click(function(){
  285 + window.location.href="{:url('user/Center/addAddress')}";
  286 + })
  287 + $(".edit").click(function(){
  288 + window.location.href=$(this).attr('data-url');
  289 + });
  290 + //删除地址
  291 + $(".defaultdel").click(function(){
  292 + id = $(this).attr('data-id');
  293 + $(".deletewrapper").show()
  294 + })
  295 +
  296 + //删除确定
  297 + $(".sure").click(function(){
  298 + $(".deletewrapper").css("display","none")
  299 + $.ajax({
  300 + url:"{:url('user/Center/delAddress')}",
  301 + data:{
  302 + id:id,
  303 + },
  304 + type:"POST",
  305 + dataType:"JSON",
  306 +
  307 + success: function (data) {
  308 + window.location.href=data.url;
  309 + }
  310 + })
  311 + })
  312 + $(".cancel").click(function(){
  313 + $(".deletewrapper").css("display","none")
  314 + })
  315 +
  316 +
  317 + //选择默认地址
  318 + console.log($(".xuan"))
  319 + $(".xuan").click(function(){
  320 + $(this).css("display","none");
  321 + $(this).siblings(".icon-xuanze-fangkuang").css("display","block");
  322 + $(this).parents(".default_list").siblings(".default_list").children(".default_body").children(".default").children(".icon-xuanze-fangkuang").css("display","none")
  323 + $(this).parents(".default_list").siblings(".default_list").children(".default_body").children(".default").children(".xuan").css("display","block")
  324 + id=$(this).attr('data-id');
  325 + $.ajax({
  326 + url:"{:url('user/Center/setDefault')}",
  327 + data:{
  328 + id:id,
  329 + is_sta:$(this).attr('data-var')
  330 + },
  331 + type:"POST",
  332 + dataType:"JSON",
  333 + })
  334 + })
  335 + $(".icon-xuanze-fangkuang").click(function(){
  336 + $(this).css("display","none");
  337 + $(this).siblings(".xuan").css("display","block")
  338 + $.ajax({
  339 + url:"{:url('user/Center/setDefault')}",
  340 + data:{
  341 + id:id,
  342 + is_sta:$(this).attr('data-var')
  343 + },
  344 + type:"POST",
  345 + dataType:"JSON",
  346 + })
  347 + })
  348 +</script>
  349 +</body>
  350 +</html>
  1 +
  2 +<!DOCTYPE html>
  3 +<html lang="en">
  4 +<head>
  5 + <meta charset="UTF-8">
  6 + <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7 + <link rel="stylesheet" href="__INDEX__/css/weui.css">
  8 + <link rel="stylesheet" href="__INDEX__/css/jquery-weui.css">
  9 + <link rel="stylesheet" href="__INDEX__/css/demos.css">
  10 + <link rel="stylesheet" href="https://at.alicdn.com/t/font_834805_9njxvxqweig.css">
  11 + <link rel="stylesheet" href="__INDEX__/css/base.css">
  12 + <link rel="stylesheet" href="__INDEX__/css/swiper.min.css">
  13 + <script type="text/javascript" src="__INDEX__/js/base.js"></script>
  14 + <title>添加地址</title>
  15 + <style>
  16 + body,html{
  17 + width:100%;
  18 + height:100%;
  19 + background: #F5F6FA;
  20 + }
  21 + .select_address{
  22 + width:6.86rem;
  23 + margin: 0 auto;
  24 + height:1.01rem;
  25 + border-bottom: 1px solid #f5f5f5;
  26 + display:flex;
  27 + /*justify-content: space-between;*/
  28 + align-items: center;
  29 + position: relative;
  30 + padding: 0 0.33rem;
  31 +
  32 + }
  33 + .weui-cell{
  34 + /*display:flex;*/
  35 + /*justify-content: space-between;*/
  36 + /*align-items: center;*/
  37 + }
  38 + .detail_address{
  39 + width:6.86rem;
  40 + margin: 0 auto;
  41 + height:1.01rem;
  42 + border-bottom: 1px solid #f5f5f5;
  43 + display:flex;
  44 + /*justify-content: space-between;*/
  45 + align-items: center;
  46 + padding: 0 0.33rem;
  47 + }
  48 + .place{
  49 + width:1.5rem;
  50 + color:#1A1A1A;
  51 + font-size: 0.3rem;
  52 + }
  53 + .detailplace{
  54 + color:#999999;
  55 + font-size: 0.3rem;
  56 + }
  57 + .province{
  58 + color:#999999;
  59 + font-size: 0.3rem;
  60 + }
  61 + .weui-label {
  62 + width:1.3rem;
  63 + }
  64 + .detailplace{
  65 + border:none;
  66 + outline: none;
  67 + /*margin-right:0.6rem;*/
  68 + }
  69 + .select{
  70 + background: #fff;
  71 + }
  72 + .save{
  73 + width:6.86rem;
  74 + height:0.88rem;
  75 + background:#FE0A01;
  76 + color:#fff;
  77 + font-size:0.32rem ;
  78 + text-align: center;
  79 + line-height: 0.88rem;
  80 + border-radius: 0.44rem;
  81 + position:fixed;
  82 + bottom:0.55rem;
  83 + left:0;
  84 + right:0;
  85 + margin: 0 auto;
  86 + box-shadow:0px 15px 30px 0px rgba(254,10,1,0.24);
  87 + }
  88 + .icon-xiaotuziCduan_{
  89 + color:#999999;
  90 + font-size: 0.5rem;
  91 + position:absolute;
  92 + right:0.3rem;
  93 + z-index: 5;
  94 + }
  95 + .selectadd{
  96 + width:4.6rem;
  97 + position:relative;
  98 + border:none;
  99 + outline:none;
  100 + z-index: 8;
  101 + /*margin-left: 0.5rem;*/
  102 + }
  103 + </style>
  104 +</head>
  105 +<body>
  106 +<div class="container">
  107 + <div class="select">
  108 + <div class="select_address">
  109 + <p class="place">选择地区</p>
  110 + <div class="weui-cell" style="padding: 0">
  111 + <!--<div class="weui-cell__hd"><label for="date" class="weui-label place">选择地区</label></div>-->
  112 + <div class="weui-cell__bd">
  113 + <input class="weui-input selectadd" id="end" type="text" placeholder="请选择省市区" value="{$data.province} {$data.city} {$data.county}" data-codes="{$data.province_id},{$data.city_id},{$data.county_id}">
  114 + </div>
  115 + </div>
  116 + <p class="iconfont icon-xiaotuziCduan_"></p>
  117 + </div>
  118 + <div class="detail_address">
  119 + <p class="place">详细地址</p>
  120 + <input id="P" type="text" placeholder="请填写详细地址" class="detailplace" value="{$data.place}">
  121 + </div>
  122 + <div class="detail_address">
  123 + <p class="place">收货人</p>
  124 + <input id="N" type="text" placeholder="请填写收货人" class="detailplace" value="{$data.name}">
  125 + </div>
  126 + <div class="detail_address">
  127 + <p class="place">联系电话</p>
  128 + <input id="M" type="text" placeholder="请填写联系电话" class="detailplace" value="{$data.mobile}">
  129 + </div>
  130 + </div>
  131 + <div class="save">保存</div>
  132 +</div>
  133 +</body>
  134 +<script type="text/javascript" src="__INDEX__/js/jquery-2.1.4.js"></script>
  135 +<script type="text/javascript" src="__INDEX__/js/fastclick.js"></script>
  136 +<script>
  137 + $(function() {
  138 + FastClick.attach(document.body);
  139 + });
  140 +</script>
  141 +<script type="text/javascript" src="__INDEX__/js/jquery-weui.js"></script>
  142 +<script type="text/javascript" src="__INDEX__/js/city-picker.js"></script>
  143 +
  144 +<script>
  145 + $("#end,.icon-xiaotuziCduan").cityPicker({
  146 + title: "请选择地区"
  147 + });
  148 +</script>
  149 +
  150 +<script>
  151 + $(".save").click(function () {
  152 + var code = $("#end").attr('data-codes');
  153 + var label = $("#end").val();
  154 + if(code == null || label == null || $("#P").val() == '' || $("#N").val() == '' || $("#M").val() == '') {
  155 + alert('请完善地址信息');
  156 + }else {
  157 + $.ajax({
  158 + url: "{:url('user/Center/editAddress')}",
  159 + data: {
  160 + code: code,
  161 + label: label,
  162 + place: $("#P").val(),
  163 + name: $("#N").val(),
  164 + mobile: $("#M").val(),
  165 + id:'{$data.id}'
  166 + },
  167 + type: "POST",
  168 + dataType: "JSON",
  169 +
  170 + success: function (data) {
  171 + window.location.href = data.url;
  172 + }
  173 + })
  174 + }
  175 + })
  176 +</script>
  177 +</html>
@@ -119,7 +119,7 @@ @@ -119,7 +119,7 @@
119 }); 119 });
120 //我的积分 120 //我的积分
121 $(".interg").click(function(){ 121 $(".interg").click(function(){
122 - window.location.href='myintegration.html' 122 + window.location.href="{:url('user/Center/myBalance')}";
123 }) 123 })
124 //关于我们 124 //关于我们
125 $(".us").click(function(){ 125 $(".us").click(function(){
  1 +
  2 +<!DOCTYPE html>
  3 +<html lang="en">
  4 +<head>
  5 + <meta charset="UTF-8">
  6 + <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7 + <link rel="stylesheet" href="https://at.alicdn.com/t/font_834805_0ml90wdq5hzm.css">
  8 + <link rel="stylesheet" href="__INDEX__/css/base.css">
  9 + <link rel="stylesheet" href="__INDEX__/css/swiper.min.css">
  10 + <script type="text/javascript" src="__INDEX__/js/base.js"></script>
  11 + <title>我的积分</title>
  12 + <style>
  13 + .head{
  14 + width:7.5rem;
  15 + height:3rem;
  16 + background:linear-gradient(-30deg,rgba(248,199,11,1),rgba(254,230,0,1));
  17 + padding-top: 0.7rem;
  18 + }
  19 + .total_integrate{
  20 + font-size:0.88rem;
  21 + color:#1A1A1A;
  22 + font-weight: bold;
  23 + width:6rem;
  24 + height:1.2rem;
  25 + margin: 0 auto;
  26 + text-align: center;
  27 + }
  28 + .remain{
  29 + width:6rem;
  30 + text-align: center;
  31 + margin: 0 auto;
  32 + font-size: 0.24rem;
  33 + color:#1A1A1A;
  34 + }
  35 + .list{
  36 + display:flex;
  37 + justify-content: space-between;
  38 + align-items: center;
  39 + padding: 0.39rem 0.32rem;
  40 + border-bottom: 1px solid #f5f5f5;
  41 +
  42 + }
  43 + .record{
  44 + font-size: 0.287rem;
  45 + color:#1A1A1A;
  46 +
  47 + }
  48 + .icon-jinru{
  49 + color:#CCCCCC
  50 + }
  51 + .integrate_list{
  52 + background: #fff;
  53 + }
  54 + </style>
  55 +</head>
  56 +<body>
  57 +<div class="container">
  58 + <div class="head">
  59 + <p class="total_integrate">{$balance}</p>
  60 + <p class="remain">积分余额</p>
  61 + </div>
  62 + <div class="integrate_list">
  63 + <div class="list takenote">
  64 + <p class="record">积分获取记录</p>
  65 + <P class="iconfont icon-jinru"></P>
  66 + </div>
  67 + <div class="list uselist">
  68 + <p class="record">积分使用记录</p>
  69 + <P class="iconfont icon-jinru"></P>
  70 + </div>
  71 + <div class="list friend">
  72 + <p class="record">赠送好友积分</p>
  73 + <P class="iconfont icon-jinru"></P>
  74 + </div>
  75 + <div class="list password">
  76 + <p class="record">积分怎样密码管理</p>
  77 + <P class="iconfont icon-jinru"></P>
  78 + </div>
  79 + </div>
  80 +</div>
  81 +</body>
  82 +<script src="__INDEX__/js/jquery.min.js"></script>
  83 +<script>
  84 + $(".takenote").click(function(){
  85 + window.location.href='gainintergral.html'
  86 + })
  87 + $(".uselist").click(function(){
  88 + window.location.href='gainintergral.html'
  89 + })
  90 + //赠送好友积分
  91 + $(".friend").click(function(){
  92 + window.location.href='friendlist.html'
  93 + })
  94 + $(".password").click(function(){
  95 + window.location.href='passwordmanager.html'
  96 + })
  97 +</script>
  98 +</html>
@@ -1831,3 +1831,21 @@ function getBanner() { @@ -1831,3 +1831,21 @@ function getBanner() {
1831 return $res; 1831 return $res;
1832 } 1832 }
1833 1833
  1834 +/**
  1835 + * 易连云打印接口
  1836 + * @param int $partner 用户ID
  1837 + * @param string $machine_code 打印机终端号
  1838 + * @param string $content 打印内容
  1839 + * @param string $apiKey API密钥
  1840 + * @param string $msign 打印机密钥
  1841 + */
  1842 +function printer($config, $content)
  1843 +{
  1844 + $partner = $config['partner'];
  1845 + $machine_code = $config['machine_code'];
  1846 + $apiKey = $config['apiKey'];
  1847 + $msign = $config['msign'];
  1848 + require_once EXTEND_PATH . 'yly/printer.php';
  1849 + $api = new \Yprint($partner, $machine_code, $content, $apiKey, $msign);
  1850 + $api->action_print();
  1851 +}
  1 +<?php
  2 +
  3 +class Yprint
  4 +{
  5 + private $partner;
  6 + private $machine_code;
  7 + private $apiKey;
  8 + private $msign;
  9 + public $content;
  10 +
  11 + function __construct($partner, $machine_code, $content, $apiKey, $msign)
  12 + {
  13 + $this->partner = $partner;
  14 + $this->machine_code = $machine_code;
  15 + $this->content = $content;
  16 + $this->apiKey = $apiKey;
  17 + $this->msign = $msign;
  18 + }
  19 +
  20 + /**
  21 + * 生成签名sign
  22 + * @param array $params 参数
  23 + * @param string $apiKey API密钥
  24 + * @param string $msign 打印机密钥
  25 + * @return string sign
  26 + */
  27 + public function generateSign($params)
  28 + {
  29 + //所有请求参数按照字母先后顺序排
  30 + ksort($params);
  31 + //定义字符串开始所包括的字符串
  32 + $stringToBeSigned = $this->apiKey;
  33 + //把所有参数名和参数值串在一起
  34 + foreach ($params as $k => $v) {
  35 + $stringToBeSigned .= urldecode($k . $v);
  36 + }
  37 + unset($k, $v);
  38 + //定义字符串结尾所包括的字符串
  39 + $stringToBeSigned .= $this->msign;
  40 + //使用MD5进行加密,再转化成大写
  41 + return strtoupper(md5($stringToBeSigned));
  42 + }
  43 +
  44 + /**
  45 + * 生成字符串参数
  46 + * @param array $param 参数
  47 + * @return string 参数字符串
  48 + */
  49 + public function getStr($param)
  50 + {
  51 + $str = '';
  52 + foreach ($param as $key => $value) {
  53 + $str = $str . $key . '=' . $value . '&';
  54 + }
  55 + $str = rtrim($str, '&');
  56 + return $str;
  57 + }
  58 +
  59 + /**
  60 + * 打印接口
  61 + * @param int $partner 用户ID
  62 + * @param string $machine_code 打印机终端号
  63 + * @param string $content 打印内容
  64 + * @param string $apiKey API密钥
  65 + * @param string $msign 打印机密钥
  66 + */
  67 + public function action_print()
  68 + {
  69 + $param = array(
  70 + "partner" => $this->partner,
  71 + 'machine_code' => $this->machine_code,
  72 + 'time' => time(),
  73 + );
  74 + //获取签名
  75 + $param['sign'] = $this->generateSign($param, $this->apiKey, $this->msign);
  76 + $param['content'] = $this->content;
  77 + $str = $this->getStr($param);
  78 + $this->sendCmd('http://open.10ss.net:8888', $str);
  79 + }
  80 +
  81 + /**
  82 + * 发起请求
  83 + * @param string $url 请求地址
  84 + * @param string $data 请求数据包
  85 + * @return string 请求返回数据
  86 + */
  87 + public function sendCmd($url, $data)
  88 + {
  89 + $curl = curl_init(); // 启动一个CURL会话
  90 + curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
  91 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检测
  92 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在
  93 + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:')); //解决数据包大不能提交
  94 + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
  95 + curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
  96 + curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
  97 + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
  98 + curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循
  99 + curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
  100 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
  101 +
  102 + $tmpInfo = curl_exec($curl); // 执行操作
  103 + if (curl_errno($curl)) {
  104 + echo 'Errno' . curl_error($curl);
  105 + }
  106 + curl_close($curl); // 关键CURL会话
  107 + return $tmpInfo; // 返回数据
  108 + }
  109 +
  110 +}