123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- ;
- layui.define(['form','upload','flow','laytpl','element'], function (e) {
- var s = layui.$,
- upload = layui.upload,
- flow = layui.flow,
- laytpl = layui.laytpl,
- element = layui.element,
- form = layui.form;
- s('.address').on('click',function(){
- layui.data('qfsc',{
- key:'history',
- value:location.href
- })
- location.href = '/index/address/index.html'
- })
- form.on('submit(layui-order-add)',function(data){
- layui.data('qfsc',{
- key:'history',
- value:null
- })
- var message = s('input[name=message]').val();
- data.field.message = message;
- data.field.account = s('input[name=account]').val();
- layer.prompt({title: '输入交易密码,并确认', formType: 1}, function(oppwd, index){
- data.field.oppwd = oppwd;
- s.post('add.html',data.field,function(r){
- layer.msg(r.msg,{time:1000,end:function(){
- if (!r.code) {
- location.href = '/index/order/index.html'
- }
- }})
- })
- layer.close(index);
- });
- return false;
- })
- element.on('tab(order)', function(data){
- var state = s(this).attr('lay-id');
- s('.list').empty();
- flow.load({
- elem: '.list'
- ,done: function(page, next){
- s.post('load.html',{page:page,state:state},function(res){
- laytpl(s('#order-list').html()).render(res.data, function(html){
- next(html, page < res.pages);
- })
- });
- }
- });
- });
- var order = function(){
- if(s('input[name=address_id]').length > 0){
- order.prototype.address();
- }
- if (s('.list').length > 0) {
- console.log(0)
- element.tabChange('order', '0')
- }
- }
- order.prototype.address = function() {
- s.post('/index/address/default',{},function(r){
- if (!r.code) {
- var rdata = r.data;
- s('input[name=address_id]').val(rdata.id)
- s('span.truename').text(rdata.truename);
- s('span.mobile').text(rdata.mobile);
- var address = rdata.area+' '+rdata.detail;
- s('span.address').text(address);
- }else{
- layer.confirm('请先添加收货地址', {
- btn: ['确定','取消']
- }, function(index){
- layer.close(index)
- layui.data('qfsc',{
- key:'history',
- value:location.href
- })
- location.href = '/index/address/index.html'
- },function(){
- history.go(-1)
- });
- }
- })
- };
- e('order',new order())
- })
|