43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
|
|
// 给上传按钮添加上传成功事件
|
|
$("#plupload-avatar").data("upload-success", function (data) {
|
|
var url = Backend.api.cdnurl(data.url);
|
|
$(".profile-user-img").prop("src", url);
|
|
Toastr.success("上传成功!");
|
|
});
|
|
|
|
// 给表单绑定事件
|
|
Form.api.bindevent($("#update-form"), function () {
|
|
$("input[name='row[password]']").val('');
|
|
var url = Backend.api.cdnurl($("#c-avatar").val());
|
|
top.window.$(".user-panel .image img,.user-menu > a > img,.user-header > img").prop("src", url);
|
|
return true;
|
|
});
|
|
|
|
|
|
$("#c-address_city").on("cp:updated", function() {
|
|
var citypicker = $(this).data("citypicker");
|
|
var province = citypicker.getCode("province");
|
|
var city = citypicker.getCode("city");
|
|
var district = citypicker.getCode("district");
|
|
if(province){
|
|
$("#province").val(province);
|
|
}
|
|
if(city){
|
|
$("#city").val(city);
|
|
}
|
|
if(district){
|
|
$("#district").val(district);
|
|
}
|
|
});
|
|
|
|
Form.api.bindevent($("#shop-form"));
|
|
},
|
|
};
|
|
return Controller;
|
|
});
|