作者 王晓刚
1 个管道 的构建 通过 耗费 1 秒

我的钱包

@@ -10,6 +10,7 @@ namespace app\home\controller; @@ -10,6 +10,7 @@ namespace app\home\controller;
10 10
11 11
12 use app\common\controller\WechatBase; 12 use app\common\controller\WechatBase;
  13 +use EasyWeChat\Foundation\Application;
13 use think\Db; 14 use think\Db;
14 15
15 class Merchant extends WechatBase 16 class Merchant extends WechatBase
@@ -31,6 +32,14 @@ class Merchant extends WechatBase @@ -31,6 +32,14 @@ class Merchant extends WechatBase
31 return $this->fetch(); 32 return $this->fetch();
32 } 33 }
33 public function enter_view(){ 34 public function enter_view(){
  35 + $options = [
  36 + 'app_id' => config('wechat.app_id'),
  37 + 'secret' => config('wechat.secret'),
  38 + ];
  39 + $app = new Application($options);
  40 + $js = $app->js;
  41 + $jssdk = $js->config(['getLocation','openLocation','chooseImage', 'uploadImage', 'previewImage'], $debug = false, $beta = false, $json = true);
  42 + $this->assign('jssdk',$jssdk);
34 return $this->fetch(); 43 return $this->fetch();
35 } 44 }
36 } 45 }
@@ -68,19 +68,51 @@ @@ -68,19 +68,51 @@
68 </div> 68 </div>
69 {include file="public/js" /} 69 {include file="public/js" /}
70 <script> 70 <script>
71 - // 营业执照  
72 - function fileImg() {  
73 - var reads = new FileReader();  
74 - var img = document.getElementById("imgFile").files[0];  
75 - reads.readAsDataURL(img);  
76 - reads.onload = function(e) {  
77 - document.getElementById('img1').src = this.result;  
78 - console.log($("#img1"))  
79 - console.log(e)  
80 - };  
81 - };  
82 - $(".btn_box").click(function() {  
83 - window.location.href = "examine.html" 71 + $(function(){
  72 + wx.config(
  73 + {$jssdk}
  74 + );
  75 + wx.ready(function () {
  76 + $('.upload').click(function () {
  77 + wx.chooseImage({
  78 + count: 1, // 默认9
  79 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  80 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  81 + success: function (res) {
  82 + $(res.localIds).each(function (key, localId) {
  83 + uploadImages(localId);
  84 + });
  85 + }
  86 + });
  87 + });
  88 + function uploadImages(localId) {
  89 + wx.uploadImage({
  90 + localId: localId,
  91 + isShowProgressTips: 1,
  92 + success: function (res) {
  93 + var serverId = res.serverId; // 返回图片的服务器端ID
  94 + $.ajax({
  95 + url:"{:url('home/upload/fetImage')}",
  96 + type:"GET",
  97 + data:{'media':serverId},
  98 + success:function(res){
  99 + console.log(res);
  100 + if(res.code == 1){
  101 + $('.upload').find('img').attr('src',res.data);
  102 + $('#avatar').val(res.data);
  103 + }
  104 + },
  105 + error:function(res){
  106 + toast('与服务器断开连接');
  107 + }
  108 + })
  109 + },
  110 + fail: function (res) {
  111 + toast(JSON.stringify(res));
  112 + }
  113 + });
  114 + }
  115 + });
84 }) 116 })
85 </script> 117 </script>
86 </body> 118 </body>

195.0 KB | 宽: | 高:

310.5 KB | 宽: | 高:

  • 两方对比
  • 交换覆盖
  • 透明覆盖