bhq@iemsoft.cn
2018-11-27 e2b48dac099e43f4b3243cdf19a7522e4b5eccbe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<div class="box">
    <div class="hd"><h3>{$lang.transform_points}</h3><div class="extra"></div></div>
    <div class="bd">
        {if $exchange_type eq 'ucenter'}
        <form action="user.php" method="post" name="transForm" onsubmit="return calcredit();">
            <table class="data_table">
                <colgroup>
                    <col width="100"/>
                    <col width="500"/>
                </colgroup>
                <tbody>
                    <tr class="odd">
                        <th>{$lang.cur_points}{$lang.colon}</th>
                        <td class="last">
                            <label for="pay_points">{$lang.exchange_points.1}{$lang.colon}</label><input type="text" name="pay_points" value="{$shop_points.pay_points}" size="15" id="pay_points" readonly="readonly"/><br />
                            <label for="rank_points">{$lang.exchange_points.0}{$lang.colon}</label><input type="text" name="rank_points" value="{$shop_points.rank_points}" size="15" id="rank_points" readonly="readonly"/>
                        </td>
                    </tr>
                    <tr class="even">
                        <th><label for="amount">{$lang.exchange_amount}{$lang.colon}</label></th>
                        <td class="last">
                            <input type="text" name="amount" value="0" size="15" id="amount" onkeyup="calcredit();"  />
                            <select name="fromcredits" id="fromcredits" onchange="calcredit();">
                            {html_options options=$lang.exchange_points selected=$selected_org}
                            </select>
                        </td>
                    </tr>
                    <tr class="odd">
                        <th><label for="desamount">{$lang.exchange_desamount}{$lang.colon}</label></th>
                        <td class="last">
                            <input type="text" name="desamount" id="desamount" disabled="disabled" value="0" size="15" />
                            <select name="tocredits" id="tocredits" onchange="calcredit();">
                            {html_options options=$to_credits_options selected=$selected_dst}
                            </select>
                        </td>
                    </tr>
                    <tr class="even last">
                        <th>{$lang.exchange_ratio}{$lang.colon}</th>
                        <td class="last">1 <span id="orgcreditunit">{$orgcreditunit}</span> <span id="orgcredittitle">{$orgcredittitle}</span> {$lang.exchange_action} <span id="descreditamount">{$descreditamount}</span> <span id="descreditunit">{$descreditunit}</span> <span id="descredittitle">{$descredittitle}</span></td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td class="last">&nbsp;</td>
                        <td class="last">
                            <input type="submit" name="transfrom" value="{$lang.transform}" class="btn_s1_b"/>
                            <input type="hidden" name="act" value="act_transform_ucenter_points"/>
                        </td>
                    </tr>
                </tfoot>
            </table>
        </form>
<script type="text/javascript">
{foreach from=$lang.exchange_js item=lang_js key=key}
var {$key} = '{$lang_js}';
{/foreach}
var out_exchange_allow = new Array();
{foreach from=$out_exchange_allow item=ratio key=key}
out_exchange_allow['{$key}'] = '{$ratio}';
{/foreach}
function calcredit() {
    var frm = document.forms['transForm'];
    var src_credit = frm.fromcredits.value;
    var dest_credit = frm.tocredits.value;
    var in_credit = frm.amount.value;
    var org_title = frm.fromcredits[frm.fromcredits.selectedIndex].innerHTML;
    var dst_title = frm.tocredits[frm.tocredits.selectedIndex].innerHTML;
    var radio = 0;
    var shop_points = ['rank_points', 'pay_points'];
    if (parseFloat(in_credit) > parseFloat(document.getElementById(shop_points[src_credit]).value)) {
        alert(balance.replace('{%s}', org_title));
        frm.amount.value = frm.desamount.value = 0;
        return false;
    }
    if (typeof(out_exchange_allow[dest_credit+'|'+src_credit]) == 'string') {
        radio = (1 / parseFloat(out_exchange_allow[dest_credit+'|'+src_credit])).toFixed(2);
    }
    document.getElementById('orgcredittitle').innerHTML = org_title;
    document.getElementById('descreditamount').innerHTML = radio;
    document.getElementById('descredittitle').innerHTML = dst_title;
    if (in_credit > 0) {
        if (typeof(out_exchange_allow[dest_credit+'|'+src_credit]) == 'string') {
            frm.desamount.value = Math.floor(parseFloat(in_credit) / parseFloat(out_exchange_allow[dest_credit+'|'+src_credit]));
            frm.transfrom.disabled = false;
            return true;
        } else {
            frm.desamount.value = deny;
            frm.transfrom.disabled = true;
            return false;
        }
    } else {
        return false;
    }
}
</script>
        {else}
        <h2 class="title"><span>{$lang.cur_points}</span><em class="extra"></em></h2>
        <table class="data_table">
            <colgroup>
                <col width="100"/>
                <col width="300"/>
            </colgroup>
            <tbody>
                {foreach from=$bbs_points item=points name=bbs_points}
                <tr class="{cycle values="odd,even"}{if $smarty.foreach.bbs_points.last} last{/if}">
                    <th>{$points.title}{$lang.colon}</th>
                    <td class="last">{$points.value}</td>
                </tr>
                {/foreach}
            </tbody>
        </table>
        <table class="data_table">
            <colgroup>
                <col width="100"/>
                <col width="300"/>
            </colgroup>
            <tbody>
                <tr class="odd">
                    <th>{$lang.pay_points}{$lang.colon}</th>
                    <td class="last">{$shop_points.pay_points}</td>
                </tr>
                <tr class="even last">
                    <th>{$lang.rank_points}{$lang.colon}</th>
                    <td class="last">{$shop_points.rank_points}</td>
                </tr>
            </tbody>
        </table>
        <h2 class="title"><span>{$lang.rule_list}</span><em class="extra"></em></h2>
        <ul class="text_list">
            {foreach from=$rule_list item=rule name=rule_list}
            <li{if $smarty.foreach.rule_list.first} class="first"{/if}>"{$rule.from}" {$lang.transform} "{$rule.to}" {$lang.rate_is} {$rule.rate}</li>
            {/foreach}
        </ul>
        <form action="user.php" method="post" name="theForm">
            <table class="data_table">
                <colgroup>
                    <col width="200"/>
                    <col width="200"/>
                    <col width="200"/>
                </colgroup>
                <thead>
                    <tr>
                        <th>{$lang.rule}</th>
                        <th>{$lang.transform_num}</th>
                        <th class="last">{$lang.transform_result}</th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="last">
                        <td><select name="rule_index" onchange="changeRule()">
                        {foreach from=$rule_list item=rule key=key}
                        <option value="{$key}">{$rule.from}->{$rule.to}</option>
                        {/foreach}
                        </select></td>
                        <td><input type="text" name="num" value="0" onkeyup="calPoints()"/></td>
                        <td class="last"><span id="ECS_RESULT">0</span></td>
                    </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="3" class="center last">
                        <input type="submit" value="{$lang.transform}" class="btn_s1_b"/>
                        <input type="hidden" name="act" value="act_transform_points"/>
                    </td>
                </tr>
                </tfoot>
            </table>
        </form>
    </div>
</div>
<script type="text/javascript">
//<![CDATA[
var rule_list = new Object();
var invalid_input = '{$lang.invalid_input}';
{foreach from=$rule_list item=rule key=key}
rule_list['{$key}'] = '{$rule.rate}';
{/foreach}
function calPoints() {
    var frm = document.forms['theForm'];
    var rule_index = frm.elements['rule_index'].value;
    var num = parseInt(frm.elements['num'].value);
    var rate = rule_list[rule_index];
    if (isNaN(num) || num < 0 || num != frm.elements['num'].value) {
        document.getElementById('ECS_RESULT').innerHTML = invalid_input;
        rerutn;
    }
    var arr = rate.split(':');
    var from = parseInt(arr[0]);
    var to = parseInt(arr[1]);
    if (from <=0 || to <=0) {
        from = 1;
        to = 0;
    }
    document.getElementById('ECS_RESULT').innerHTML = parseInt(num * to / from);
}
function changeRule() {
    document.forms['theForm'].elements['num'].value = 0;
    document.getElementById('ECS_RESULT').innerHTML = 0;
}
//]]>
</script>
{/if}