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

我的钱包

... ... @@ -10,6 +10,7 @@ namespace app\home\controller;
use app\common\controller\WechatBase;
use EasyWeChat\Foundation\Application;
use think\Db;
class Merchant extends WechatBase
... ... @@ -31,6 +32,14 @@ class Merchant extends WechatBase
return $this->fetch();
}
public function enter_view(){
$options = [
'app_id' => config('wechat.app_id'),
'secret' => config('wechat.secret'),
];
$app = new Application($options);
$js = $app->js;
$jssdk = $js->config(['getLocation','openLocation','chooseImage', 'uploadImage', 'previewImage'], $debug = false, $beta = false, $json = true);
$this->assign('jssdk',$jssdk);
return $this->fetch();
}
}
\ No newline at end of file
... ...
... ... @@ -68,19 +68,51 @@
</div>
{include file="public/js" /}
<script>
// 营业执照
function fileImg() {
var reads = new FileReader();
var img = document.getElementById("imgFile").files[0];
reads.readAsDataURL(img);
reads.onload = function(e) {
document.getElementById('img1').src = this.result;
console.log($("#img1"))
console.log(e)
};
};
$(".btn_box").click(function() {
window.location.href = "examine.html"
$(function(){
wx.config(
{$jssdk}
);
wx.ready(function () {
$('.upload').click(function () {
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
$(res.localIds).each(function (key, localId) {
uploadImages(localId);
});
}
});
});
function uploadImages(localId) {
wx.uploadImage({
localId: localId,
isShowProgressTips: 1,
success: function (res) {
var serverId = res.serverId; // 返回图片的服务器端ID
$.ajax({
url:"{:url('home/upload/fetImage')}",
type:"GET",
data:{'media':serverId},
success:function(res){
console.log(res);
if(res.code == 1){
$('.upload').find('img').attr('src',res.data);
$('#avatar').val(res.data);
}
},
error:function(res){
toast('与服务器断开连接');
}
})
},
fail: function (res) {
toast(JSON.stringify(res));
}
});
}
});
})
</script>
</body>
... ...

195.0 KB | 宽: | 高:

310.5 KB | 宽: | 高:

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