Commit a3d2beaa8c5eb40e1af47250587d8ff41f577fcc

Authored by 范牧
1 parent 5638d36da2
Exists in master

立即支付功能

src/components/CommodityCard/CommodityCard.vue
... ... @@ -47,10 +47,10 @@ export default {
47 47 }
48 48 },
49 49 methods: {
50   - toGoods (id, sk_id) {
51   - console.log('---', '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id)
  50 + toGoods (id, skId) {
  51 + console.log('---', '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + skId)
52 52 uni.navigateTo({
53   - url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id,
  53 + url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + skId,
54 54 success: res => {},
55 55 fail: () => {},
56 56 complete: () => {},
... ...
src/pages/cart/cart.vue
1 1 <template>
2   - <view class="content">
3   - <block v-if="cartList.length==0">
  2 + <view class="content">
  3 + <block v-if="cartList.length==0">
4 4  
5   - </block>
6   - <block v-else>
7   - <view class="card">
8   - <view class="cardHeader">
9   - <view v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'"
10   - @tap="pChange(pIsoPen)">
11   - <span class="correct"></span>
12   - </view>
13   - <image src="../../static/store.png" mode="aspectFill"></image>
14   - <text>非常戴镜</text>
15   - </view>
  5 + </block>
  6 + <block v-else>
  7 + <view class="card">
  8 + <view class="cardHeader">
  9 + <view
  10 + v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'"
  11 + @tap="pChange(pIsoPen)"
  12 + >
  13 + <span class="correct"></span>
  14 + </view>
  15 + <image
  16 + src="../../static/store.png"
  17 + mode="aspectFill"
  18 + ></image>
  19 + <text>非常戴镜</text>
  20 + </view>
16 21  
17   - <view class="cardBody" v-for="(item,index) in cartList" :key="item.cart_id"
18   - @longpress="delCart(item.cart_id,index)">
19   - <view v-bind:class="childIsOpen[index]? 'partentChecked':'partentCheck'"
20   - @tap="Change(childIsOpen[index],index)">
21   - <span class="correct"></span>
22   - </view>
23   - <view class="imageWrap">
24   - <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image>
25   - </view>
26   - <view class="goodInfo">
27   -<!-- <view class="imageWrap">
  22 + <view
  23 + class="cardBody"
  24 + v-for="(item,index) in cartList"
  25 + :key="item.cart_id"
  26 + @longpress="delCart(item.cart_id,index)"
  27 + >
  28 + <view
  29 + v-bind:class="childIsOpen[index]? 'partentChecked':'partentCheck'"
  30 + @tap="Change(childIsOpen[index],index)"
  31 + >
  32 + <span class="correct"></span>
  33 + </view>
  34 + <view class="imageWrap">
  35 + <image
  36 + :src="item.img_index_url"
  37 + mode="aspectFit"
  38 + style="width: 188rpx;height: 168rpx;"
  39 + ></image>
  40 + </view>
  41 + <view class="goodInfo">
  42 + <!-- <view class="imageWrap">
28 43 <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image>
29 44 </view> -->
30   - <view class="infoRight">
31   - <view class="goodName" @tap="toGoods(item.pid,item.sk_id)">{{item.p_name}}</view>
32   - <!-- <view class="describ"> -->
33   - <uni-collapse accordion="true" >
34   - <uni-collapse-item showAnimation='true'
35   - :title="item.tag.prod_tag_fun[0].label+'/'+item.tag.prod_tag_fun[1].label+'/'+item.tag.prod_tag_fun[2].label+'...' || '暂无'" >
36   - <text class="describ">
37   - <block v-for="tag in item.tag.prod_tag_fun" :key="tag.value">
38   - {{tag.label+`&nbsp;&nbsp;`}}
39   - </block>
40   - </text>
41   -<!-- <text>
  45 + <view class="infoRight">
  46 + <view
  47 + class="goodName"
  48 + @tap="toGoods(item.pid,item.sk_id)"
  49 + >{{item.p_name}}</view>
  50 + <!-- <view class="describ"> -->
  51 + <uni-collapse accordion="true">
  52 + <uni-collapse-item
  53 + showAnimation='true'
  54 + :title="item.tag.prod_tag_fun[0].label+'/'+item.tag.prod_tag_fun[1].label+'/'+item.tag.prod_tag_fun[2].label+'...' || '暂无'"
  55 + >
  56 + <text class="describ">
  57 + <block
  58 + v-for="tag in item.tag.prod_tag_fun"
  59 + :key="tag.value"
  60 + >
  61 + {{tag.label+`&nbsp;&nbsp;`}}
  62 + </block>
  63 + </text>
  64 + <!-- <text>
42 65 <block v-for="tag in item.tag.prod_tag_style" :key="tag.value">
43 66 {{tag.label+`&nbsp;&nbsp;`}}
44 67 </block>
45 68 </text> -->
46   - </uni-collapse-item>
47   - </uni-collapse>
48   - <!-- <view v-bind:class="collapseList[index]? 'icon':'iconed'"></view> -->
49   - <!-- </view> -->
50   - <view class="priceBox">
51   - <view class="price">¥{{item.nowPrice*item.num}}</view>
52   - <text class="maxCount">(限购{{maxCount}}副)</text>
53   - <view class="counter">
54   - <view class="btn" disabled="this.addDisabled" type="default"
55   - @tap="counter(index,false,item)">-</view>
56   - <text>{{item.num}}</text>
57   - <view class="btn" disabled="this.desDisabled" type="default"
58   - @tap="counter(index,true,item)">+</view>
59   - </view>
60   - </view>
61   - </view>
62   - </view>
63   - </view>
64   - </view>
65   - </block>
66   - <view class="footer">
67   - <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view>
68   - <view class="footerRight">
69   - <navigator url="/pages/confirmOrder/confirmOrder" hover-class="navigator-hover">
70   - <view class="paybtn" >立即结算</view>
71   - </navigator>
72   - </view>
73   - </view>
  69 + </uni-collapse-item>
  70 + </uni-collapse>
  71 + <!-- <view v-bind:class="collapseList[index]? 'icon':'iconed'"></view> -->
  72 + <!-- </view> -->
  73 + <view class="priceBox">
  74 + <view class="price">¥{{item.nowPrice*item.num}}</view>
  75 + <text class="maxCount">(限购{{maxCount}}副)</text>
  76 + <view class="counter">
  77 + <view
  78 + class="btn"
  79 + disabled="this.addDisabled"
  80 + type="default"
  81 + @tap="counter(index,false,item)"
  82 + >-</view>
  83 + <text>{{item.num}}</text>
  84 + <view
  85 + class="btn"
  86 + disabled="this.desDisabled"
  87 + type="default"
  88 + @tap="counter(index,true,item)"
  89 + >+</view>
  90 + </view>
  91 + </view>
  92 + </view>
  93 + </view>
  94 + </view>
  95 + </view>
  96 + </block>
  97 + <view class="footer">
  98 + <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view>
  99 + <view class="footerRight">
  100 + <navigator
  101 + url="/pages/confirmOrder/confirmOrder"
  102 + hover-class="navigator-hover"
  103 + >
  104 + <view class="paybtn">立即结算</view>
  105 + </navigator>
  106 + </view>
  107 + </view>
74 108  
75   - </view>
  109 + </view>
76 110 </template>
77 111  
78 112 <script>
... ... @@ -87,7 +121,7 @@ export default {
87 121 totalPrice: 0,
88 122 pIsoPen: false,
89 123 // childIsOpen:[],
90   - maxCount: 20
  124 + maxCount: 20,
91 125 }
92 126 },
93 127 computed: {
... ... @@ -104,34 +138,34 @@ export default {
104 138 }
105 139 console.log('this.childisOPne===>', temp)
106 140 return temp
107   - }
  141 + },
108 142 },
109 143 onLoad: function() {
110 144 // store.dispatch('cart/addCart', {
111 145 // uid: this.$store.state.user.userInfo.uid,
112   - // openid: this.$store.state.user.userInfo.openid,
113   - // mp_id: 7,
114   - // sk_id: 7,
115   - // num: 1,
116   - // pid: 8,
117   - // price: 128,
118   - // checkedSKU:{},
  146 + // openid: this.$store.state.user.userInfo.openid,
  147 + // mp_id: 7,
  148 + // sk_id: 7,
  149 + // num: 1,
  150 + // pid: 8,
  151 + // price: 128,
  152 + // checkedSKU:{},
119 153 // })
120 154 store.dispatch('cart/getCartList', {
121   - uid: this.$store.state.user.userInfo.uid // 用户id
  155 + uid: this.$store.state.user.userInfo.uid, // 用户id
122 156 })
123 157 },
124 158  
125 159 methods: {
126 160  
127 161 toGoods(id, sk_id) {
128   - console.log('cart-list', this.$store.state.cart.cartList);
129   - console.log('---', '../frameDetail/frameDetail?pid=' + id +'&sk_id='+sk_id)
  162 + console.log('cart-list', this.$store.state.cart.cartList)
  163 + console.log('---', '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id)
130 164 uni.navigateTo({
131   - url: '../frameDetail/frameDetail?pid=' + id+'&sk_id='+sk_id,
  165 + url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id,
132 166 success: res => {},
133 167 fail: () => {},
134   - complete: () => {}
  168 + complete: () => {},
135 169 })
136 170 // uni.navigateTo({
137 171 // url: '../frameDetail/frameDetail?oderId=' + id,
... ... @@ -181,9 +215,9 @@ export default {
181 215 counter(index, isadd, item) {
182 216 // console.log('===>>counter ===>num',num)
183 217 // console.log('===>>counter ===>isadd',isadd)
184   - console.log('item=====>',item)
185   - console.log('num=====>',item.num)
186   - let nums = parseInt(item.num)
  218 + console.log('item=====>', item)
  219 + console.log('num=====>', item.num)
  220 + const nums = parseInt(item.num)
187 221 if (isadd) {
188 222 if (nums >= this.maxCount) {
189 223 this.addDisabled = true
... ... @@ -198,14 +232,14 @@ export default {
198 232 openid: this.$store.state.user.userInfo.openid,
199 233 mp_id: item.mp_id,
200 234 sk_id: item.sk_id,
201   - price: item.nowPrice,
202   - pid: item.pid,
  235 + price: item.nowPrice,
  236 + pid: item.pid,
203 237 num: nums + 1,
204   - cart_id: item.cart_id,
  238 + cart_id: item.cart_id,
205 239 args: {
206 240 index: index,
207   - isadd: isadd
208   - }
  241 + isadd: isadd,
  242 + },
209 243 })
210 244 this.addDisabled = false
211 245 }
... ... @@ -216,21 +250,21 @@ export default {
216 250 this.desDisabled = false
217 251 // post 请求修改相关参数
218 252 if (this.childIsOpen[index]) {
219   - this.totalPrice = this.totalPrice - this.$store.state.cart.cartList[index].nowPrice
  253 + this.totalPrice = this.totalPrice - this.$store.state.cart.cartList[index].nowPrice
220 254 }
221 255 store.dispatch('cart/modiCart', {
222 256 uid: this.$store.state.user.userInfo.uid,
223 257 openid: this.$store.state.user.userInfo.openid,
224 258 mp_id: item.mp_id,
225 259 sk_id: item.sk_id,
226   - price: item.nowPrice,
227   - pid: item.pid,
  260 + price: item.nowPrice,
  261 + pid: item.pid,
228 262 num: nums - 1,
229   - cart_id: item.cart_id,
  263 + cart_id: item.cart_id,
230 264 args: {
231 265 index: index,
232   - isadd: isadd
233   - }
  266 + isadd: isadd,
  267 + },
234 268 })
235 269 this.desDisabled = true
236 270 }
... ... @@ -282,8 +316,8 @@ export default {
282 316 // console.log('delcart------>cart_id',cart_id)
283 317 // console.log('cartlist====>delcart',this.$store.state.cart.cartList)
284 318 // console.log('delcart======>index',index)
285   - const uid=this.$store.state.user.userInfo.uid
286   - const openid=this.$store.state.user.userInfo.openid
  319 + const uid = this.$store.state.user.userInfo.uid
  320 + const openid = this.$store.state.user.userInfo.openid
287 321 uni.showModal({
288 322 title: '是否删除该商品',
289 323 // content: '是否删除该商品',
... ... @@ -294,261 +328,259 @@ export default {
294 328 uid: uid,
295 329 openid: openid,
296 330 cart_id: cart_id, // 要修改的购物车id
297   - arg: index // 由于action 传参是能接收两参数,因此将index放入对象
  331 + arg: index, // 由于action 传参是能接收两参数,因此将index放入对象
298 332 })
299 333 console.log('用户点击确定')
300 334 }
301   - }
  335 + },
302 336 })
303   - }
304   - }
  337 + },
  338 + },
305 339 }
306 340 </script>
307 341  
308 342 <style lang="scss">
309 343 .content {
310   - min-height: 100vh;
311   - background-color: #f2f2f2;
312   - display: flex;
313   - flex-direction: column;
314   - align-items: center;
315   - justify-content: space-between;
316   - padding: 20rpx 40rpx;
317   - box-sizing: border-box;
318   -
319   - .partentCheck{
320   - width: 16px;
321   - height: 16px;
322   - border-radius: 22px;
323   - border: 1px solid #CFCFCF;
324   - background-color: #FFFFFF;
325   - margin: 6px;
326   - }
327   - .partentChecked{
328   - width: 18px;
329   - height: 18px;
330   - border-radius: 22px;
331   - background-color: #FF6B4A;
332   - margin: 6px;
333   - .correct {
334   - display: inline-block;
335   - position: relative;
336   - width: 10rpx;
337   - height: 2rpx;
338   - background: #FFFFFF;
339   - line-height: 0;
340   - font-size: 0;
341   - position: relative;
342   - top: -7px;
343   - left: 4px;
344   - -webkit-transform: rotate(45deg);
345   - }
346   - .correct:after {
347   - content: '/';
348   - display: block;
349   - width: 16rpx;
350   - height: 2rpx;
351   - background: #FFFFFF;
352   - -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%);
353   - }
354   - }
355   -
356   - .card{
357   - background-color: #FFFFFF;
358   - border-radius: 16rpx;
359   - box-sizing: border-box;
360   - padding: 36rpx 36rpx 36rpx 18rpx;
361   - display: flex;
362   - flex-direction: column;
363   - align-items: center;
364   - justify-content: space-between;
365   - margin-bottom: 180rpx;
366   - .cardHeader{
367   - width: 100%;
368   - height: 36rpx;
369   - display: flex;
370   - align-items: center;
371   - justify-content: flex-start;
372   - margin-bottom: 20rpx;
373   - image{
374   - height: 32rpx;
375   - width: 32rpx;
376   - padding-left: 6px;
377   - padding-right: 10px;
378   - }
379   - text{
380   - // font-family: PingFangSC-Regular;
381   - font-size: 14px;
382   - color: #333333;
383   - letter-spacing: -0.26px;
384   - }
385   - }
386   - .cardBody{
387   - width: 100%;
388   - min-height: 300rpx;
389   - display: flex;
390   - align-items: center;
391   - justify-content: space-between;
392   - .goodInfo{
393   - width: 390rpx;
394   - display: flex;
395   - flex-direction: row;
396   - justify-content: flex-start;
397   - padding-left: 6px;
  344 + min-height: 100vh;
  345 + background-color: #f2f2f2;
  346 + display: flex;
  347 + flex-direction: column;
  348 + align-items: center;
  349 + justify-content: space-between;
  350 + padding: 20rpx 40rpx;
  351 + box-sizing: border-box;
398 352  
399   - .imageWrap{
400   - height: 188rpx;
401   - width: 188rpx;
402   - margin-right: 28rpx;
  353 + .partentCheck {
  354 + width: 16px;
  355 + height: 16px;
  356 + border-radius: 22px;
  357 + border: 1px solid #cfcfcf;
  358 + background-color: #ffffff;
  359 + margin: 6px;
  360 + }
  361 + .partentChecked {
  362 + width: 18px;
  363 + height: 18px;
  364 + border-radius: 22px;
  365 + background-color: #ff6b4a;
  366 + margin: 6px;
  367 + .correct {
  368 + display: inline-block;
  369 + position: relative;
  370 + width: 10rpx;
  371 + height: 2rpx;
  372 + background: #ffffff;
  373 + line-height: 0;
  374 + font-size: 0;
  375 + position: relative;
  376 + top: -7px;
  377 + left: 4px;
  378 + -webkit-transform: rotate(45deg);
  379 + }
  380 + .correct:after {
  381 + content: "/";
  382 + display: block;
  383 + width: 16rpx;
  384 + height: 2rpx;
  385 + background: #ffffff;
  386 + -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%);
  387 + }
  388 + }
403 389  
404   - image{
405   - border-radius: 4px;
406   - height: 188rpx;
407   - width: 188rpx;
408   - }
409   - }
410   - .infoRight{
411   - display: flex;
412   - flex-direction: column;
413   - align-items: flex-start;
414   - justify-content: space-between;
415   - min-height: 240rpx;
416   - .goodName{
417   - display: -webkit-box;
418   - -webkit-box-orient: vertical;
419   - -webkit-line-clamp: 2;
420   - text-align: justify;
421   - overflow: hidden;
422   - font-size: 28rpx;
423   - color: #333333;
424   - }
425   - .describ{
426   - width: 100%;
427   - // min-height: 80rpx;
428   - // box-sizing: border-box;
429   - // padding: 10rpx;
430   - font-size: 20rpx;
431   - letter-spacing: -0.23px;
432   - text-align: justify;
433   - color: #999999;
434   - // background: #F9F9F9;
435   - // display: flex;
436   - // justify-content: center;
437   - // align-items: center;
438   - // text{
439   - // text-overflow: -o-ellipsis-lastline;
440   - // overflow: hidden;
441   - // text-overflow: ellipsis;
442   - // display: -webkit-box;
443   - // -webkit-line-clamp: 2;
444   - // line-clamp: 2;
445   - // -webkit-box-orient: vertical;
446   - // }
447   - // .icon {
448   - // width: 0;
449   - // height: 0;
450   - // border-left: 5px transparent;
451   - // border-right: 5px transparent;
452   - // border-top: 5px #979797;
453   - // border-bottom: 0 transparent;
454   - // border-style: solid;
455   - // position: relative;
456   - // margin-left: 10px;
457   - // // transform: scaleY(-1);
458   - // }
459   - // .icon::after{
460   - // content: '';
461   - // position: absolute;
462   - // top: -6.5px;
463   - // left: -5px;
464   - // border-left: 5px transparent;
465   - // border-right: 5px transparent;
466   - // border-top: 5px #FFFFFF;
467   - // border-bottom: 0 transparent;
468   - // border-style: solid;
469   - // }
470   - }
471   - .priceBox{
472   - display: flex;
473   - justify-content: space-between;
474   - align-items: center;
475   - // margin-top: 26px;
476   - width: 100%;
477   - font-size: 14px;
478   - color: #999999;
479   - .maxCount{
480   - color: #999999;
481   - font-size: 24rpx;
482   - }
483   - .price{
484   - color: #FF6B4A;
485   - font-size: 28rpx;
486   - }
487   - .counter{
488   - display: flex;
489   - flex-direction: row;
490   - justify-content: space-between;
491   - align-items: center;
492   - font-size: 28rpx;
493   - color: #333333;
494   - width: 122rpx;
495   - .btn{
496   - display: flex;
497   - justify-content: center;
498   - line-height: 32rpx;
499   - height: 32rpx;
500   - width: 32rpx;
501   - background-color: #F2F2F2;
502   - color: #CFCFCF;
503   - }
504   - }
505   - }
506   - }
507   - }
508   - }
509   - }
  390 + .card {
  391 + background-color: #ffffff;
  392 + border-radius: 16rpx;
  393 + box-sizing: border-box;
  394 + padding: 36rpx 36rpx 36rpx 18rpx;
  395 + display: flex;
  396 + flex-direction: column;
  397 + align-items: center;
  398 + justify-content: space-between;
  399 + margin-bottom: 180rpx;
  400 + .cardHeader {
  401 + width: 100%;
  402 + height: 36rpx;
  403 + display: flex;
  404 + align-items: center;
  405 + justify-content: flex-start;
  406 + margin-bottom: 20rpx;
  407 + image {
  408 + height: 32rpx;
  409 + width: 32rpx;
  410 + padding-left: 6px;
  411 + padding-right: 10px;
  412 + }
  413 + text {
  414 + // font-family: PingFangSC-Regular;
  415 + font-size: 14px;
  416 + color: #333333;
  417 + letter-spacing: -0.26px;
  418 + }
  419 + }
  420 + .cardBody {
  421 + width: 100%;
  422 + min-height: 300rpx;
  423 + display: flex;
  424 + align-items: center;
  425 + justify-content: space-between;
  426 + .goodInfo {
  427 + width: 390rpx;
  428 + display: flex;
  429 + flex-direction: row;
  430 + justify-content: flex-start;
  431 + padding-left: 6px;
510 432  
511   - .footer{
512   - position: fixed;
513   - left: 0;
514   - bottom: 0px;
515   - height: 112rpx;
516   - width: 100%;
517   - background-color: #FFFFFF;
518   - font-size: 16px;
519   - display: flex;
520   - justify-content: space-between;
521   - align-items: center;
522   - .footerLeft{
523   - display: flex;
524   - justify-content: center;
525   - align-items: center;
526   - width: 50%;
527   - color: #333333;
528   - text{
529   - color: #FF6B4A;
530   - }
531   - }
532   - .footerRight{
533   - display: flex;
534   - justify-content: flex-end;
535   - align-items: center;
536   - width: 50%;
537   - margin-right: 26rpx;
538   - .paybtn{
539   - display: flex;
540   - justify-content: center;
541   - align-items: center;
542   - background: #FF6B4A;
543   - border-radius: 20px;
544   - border-radius: 20px;
545   - color: #FFFFFF;
546   - width: 204rpx;
547   - height: 80rpx;
548   - }
549   - }
  433 + .imageWrap {
  434 + height: 188rpx;
  435 + width: 188rpx;
  436 + margin-right: 28rpx;
550 437  
551   - }
552   - }
  438 + image {
  439 + border-radius: 4px;
  440 + height: 188rpx;
  441 + width: 188rpx;
  442 + }
  443 + }
  444 + .infoRight {
  445 + display: flex;
  446 + flex-direction: column;
  447 + align-items: flex-start;
  448 + justify-content: space-between;
  449 + min-height: 240rpx;
  450 + .goodName {
  451 + display: -webkit-box;
  452 + -webkit-box-orient: vertical;
  453 + -webkit-line-clamp: 2;
  454 + text-align: justify;
  455 + overflow: hidden;
  456 + font-size: 28rpx;
  457 + color: #333333;
  458 + }
  459 + .describ {
  460 + width: 100%;
  461 + // min-height: 80rpx;
  462 + // box-sizing: border-box;
  463 + // padding: 10rpx;
  464 + font-size: 20rpx;
  465 + letter-spacing: -0.23px;
  466 + text-align: justify;
  467 + color: #999999;
  468 + // background: #F9F9F9;
  469 + // display: flex;
  470 + // justify-content: center;
  471 + // align-items: center;
  472 + // text{
  473 + // text-overflow: -o-ellipsis-lastline;
  474 + // overflow: hidden;
  475 + // text-overflow: ellipsis;
  476 + // display: -webkit-box;
  477 + // -webkit-line-clamp: 2;
  478 + // line-clamp: 2;
  479 + // -webkit-box-orient: vertical;
  480 + // }
  481 + // .icon {
  482 + // width: 0;
  483 + // height: 0;
  484 + // border-left: 5px transparent;
  485 + // border-right: 5px transparent;
  486 + // border-top: 5px #979797;
  487 + // border-bottom: 0 transparent;
  488 + // border-style: solid;
  489 + // position: relative;
  490 + // margin-left: 10px;
  491 + // // transform: scaleY(-1);
  492 + // }
  493 + // .icon::after{
  494 + // content: '';
  495 + // position: absolute;
  496 + // top: -6.5px;
  497 + // left: -5px;
  498 + // border-left: 5px transparent;
  499 + // border-right: 5px transparent;
  500 + // border-top: 5px #FFFFFF;
  501 + // border-bottom: 0 transparent;
  502 + // border-style: solid;
  503 + // }
  504 + }
  505 + .priceBox {
  506 + display: flex;
  507 + justify-content: space-between;
  508 + align-items: center;
  509 + // margin-top: 26px;
  510 + width: 100%;
  511 + font-size: 14px;
  512 + color: #999999;
  513 + .maxCount {
  514 + color: #999999;
  515 + font-size: 24rpx;
  516 + }
  517 + .price {
  518 + color: #ff6b4a;
  519 + font-size: 28rpx;
  520 + }
  521 + .counter {
  522 + display: flex;
  523 + flex-direction: row;
  524 + justify-content: space-between;
  525 + align-items: center;
  526 + font-size: 28rpx;
  527 + color: #333333;
  528 + width: 122rpx;
  529 + .btn {
  530 + display: flex;
  531 + justify-content: center;
  532 + line-height: 32rpx;
  533 + height: 32rpx;
  534 + width: 32rpx;
  535 + background-color: #f2f2f2;
  536 + color: #cfcfcf;
  537 + }
  538 + }
  539 + }
  540 + }
  541 + }
  542 + }
  543 + }
553 544  
  545 + .footer {
  546 + position: fixed;
  547 + left: 0;
  548 + bottom: 0px;
  549 + height: 112rpx;
  550 + width: 100%;
  551 + background-color: #ffffff;
  552 + font-size: 16px;
  553 + display: flex;
  554 + justify-content: space-between;
  555 + align-items: center;
  556 + .footerLeft {
  557 + display: flex;
  558 + justify-content: center;
  559 + align-items: center;
  560 + width: 50%;
  561 + color: #333333;
  562 + text {
  563 + color: #ff6b4a;
  564 + }
  565 + }
  566 + .footerRight {
  567 + display: flex;
  568 + justify-content: flex-end;
  569 + align-items: center;
  570 + width: 50%;
  571 + margin-right: 26rpx;
  572 + .paybtn {
  573 + display: flex;
  574 + justify-content: center;
  575 + align-items: center;
  576 + background: #ff6b4a;
  577 + border-radius: 20px;
  578 + border-radius: 20px;
  579 + color: #ffffff;
  580 + width: 204rpx;
  581 + height: 80rpx;
  582 + }
  583 + }
  584 + }
  585 +}
554 586 </style>
... ...
src/pages/confirmOrder/confirmOrder.vue
... ... @@ -62,8 +62,8 @@
62 62 <text class="remarks">支持7天无理由退货 顺丰发货</text>
63 63 <view class="priceBox">
64 64 <view class="price">¥{{Number(skuInfo.real_price) * count}}<text class="originCost">
65   - ¥{{parseInt(skuInfo.real_price * (1 + Number(skuInfo.discount) / 100))}}
66   - </text></view>
  65 + ¥{{parseInt(skuInfo.real_price * (1 + Number(skuInfo.discount) / 100))}}
  66 + </text></view>
67 67 <view class="counter">
68 68 <view
69 69 class="btn"
... ... @@ -82,12 +82,13 @@
82 82 </view>
83 83 </view>
84 84 <view class="infoBottom">
85   - <view class="norm">规格 <text >
86   - <!-- 长度超出变省略号未做 -->
87   - <block
88   - v-for="(item, index) in current"
89   - :key="index"
90   - >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block></block>
  85 + <view class="norm">规格 <text>
  86 + <!-- 长度超出变省略号未做 -->
  87 + <block
  88 + v-for="(item, index) in current"
  89 + :key="index"
  90 + >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block>
  91 + </block>
91 92 </text></view>
92 93 <view class="shippingMethod">配送方式 <text>快递</text></view>
93 94 <view class="message">买家留言
... ... @@ -171,6 +172,7 @@
171 172  
172 173 <script>
173 174 import store from '@/store'
  175 +import MD5Util from '../../utils/md5'
174 176  
175 177 export default {
176 178 data() {
... ... @@ -248,6 +250,9 @@ export default {
248 250 },
249 251 // 下单
250 252 orderBuild() {
  253 + uni.showLoading({
  254 + title: '支付中',
  255 + })
251 256 console.log('this', this.$store.state)
252 257 const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param
253 258 store.dispatch('order/buyNow', {
... ... @@ -268,6 +273,8 @@ export default {
268 273 console.log('pay', res)
269 274 const { data, exKeyName: keyName } = res
270 275 const uid = uni.getStorageSync('uid')
  276 + const timeStamp = new Date().getTime().toString()
  277 + const nonceStr = 'asfafasfasfasfasf'
271 278 const fieldSet = {
272 279 openid: this.$store.state.user.userInfo.openid,
273 280 uid: this.$store.state.user.userInfo.uid,
... ... @@ -275,16 +282,55 @@ export default {
275 282 payCate: 2020,
276 283 payMoney: Number(this.skuInfo.real_price) * this.count * 100,
277 284 payWoodId: `fcdj-${uid}-${keyName}`,
278   - nonceStr: 'asfafasfasfasfasf',
  285 + payWoodDesc: '在【非常戴镜】的微信付款凭证',
  286 + nonceStr,
279 287 signType: 'MD5',
280 288 app_uid: 2020,
281   - timeStamp: new Date().getTime().toString(),
282   - billInfo: JSON.stringify(data),
  289 + timeStamp,
283 290 keyname: keyName,
  291 + billInfo: JSON.stringify(data),
284 292 }
285 293 console.log('fieldSet', fieldSet)
286   - store.dispatch('order/pay', fieldSet).then((res) => {
287   - console.log('res', res)
  294 + store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => {
  295 + if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') {
  296 + const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}`
  297 + const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789'
  298 + uni.requestPayment({
  299 + appId: data.appid,
  300 + timeStamp,
  301 + nonceStr,
  302 + total_fee: Number(this.skuInfo.real_price) * this.count * 100,
  303 + package: `prepay_id=${data.prepay_id}`,
  304 + signType: 'MD5',
  305 + paySign: MD5Util.MD5(stringSignTemp).toUpperCase(),
  306 + success: (res) => {
  307 + uni.showModal({
  308 + content: '支付成功',
  309 + showCancel: false,
  310 + })
  311 + console.log('res-----支付成功', res)
  312 + uni.reLaunch({
  313 + url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=1&ispay=1`,
  314 + })
  315 + },
  316 + fail: (res) => {
  317 + uni.showModal({
  318 + content: '支付失败',
  319 + showCancel: false,
  320 + })
  321 + console.log('res------支付失败', res)
  322 + uni.reLaunch({
  323 + url: `../myOrderPaying/myOrderPaying?payId=${payId}&state=0&ispay=1`,
  324 + })
  325 + },
  326 + complete: () => {
  327 + uni.hideLoading()
  328 + },
  329 + })
  330 + } else {
  331 + console.log('支付失败')
  332 + uni.hideLoading()
  333 + }
288 334 })
289 335 },
290 336 },
... ...
src/pages/frameDetail/frameDetail.vue
... ... @@ -382,12 +382,12 @@ export default {
382 382 },
383 383 }
384 384 },
385   - onLoad: function ({ pid, sk_id }) {
  385 + onLoad: function ({ pid, sk_id: skId }) {
386 386 this.pid = pid
387 387 // console.log('sk_id=====>',sk_id)
388 388 store.dispatch('read/fetch', {
389 389 pid,
390   - sk_id,
  390 + sk_id: skId,
391 391 }).then(() => {
392 392 this.parameter[0].slength = `${this.goodInfo.frame_width}mm`
393 393 this.parameter[1].slength = `${this.goodInfo.glass_width}mm`
... ... @@ -397,7 +397,7 @@ export default {
397 397 this.parameter[5].slength = `${this.goodInfo.weight}mm`
398 398 this.tag = this.goodInfo.tag
399 399 this.test = this.goodInfo.prodIntro1
400   - this.test = this.test.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
  400 + this.test = this.test.replace(/\<img/gi, '<img style="max-width:100%;height:auto"')
401 401 // addCart
402 402 this.addCartList.price = this.goodInfo.p_sale_price
403 403 this.addCartList.sk_id = this.goodInfo.skuList[0].sk_id
... ...
src/pages/myOrder/components/OrderCard.vue
... ... @@ -9,10 +9,10 @@
9 9 <text class="orderType" v-if="status == '2'||status == '3'">已完成</text>
10 10 <!-- <text class="orderType" v-if="status == '3'">已评价</text> -->
11 11 </view>
12   - <view class="orderCardInfo" v-for="(orderInfo) in orderInfoList.list" :key="orderInfo">
  12 + <view class="orderCardInfo" v-for="(orderInfo, index) in orderInfoList.list" :key="index">
13 13 <image :src="orderInfo.imgUrl" mode="aspectFill"></image>
14 14 <view class="infoText">
15   - <view class="orderName">{{orderInfo.p_name}}</view>
  15 + <view class="orderName">{{orderInfo[0].p_name}}</view>
16 16 <view class="orderDescrib">{{orderInfo.p_name}}</view>
17 17 <view class="infoText-bottom">
18 18 <view class="markPrice">{{orderInfo.nowPrice}}</view>
... ... @@ -164,6 +164,7 @@
164 164 return this.order.status
165 165 },
166 166 orderInfoList(){
  167 + console.log('this.order.order_info[0]', this.order)
167 168 return this.order.order_info[0]
168 169 }
169 170 },
... ...
src/pages/myOrderPaying/myOrderPaying.vue
... ... @@ -72,7 +72,7 @@
72 72 </view> -->
73 73 <text class="order-info-freight">
74 74 <text class="p1">运费</text>
75   - <text class="p2">{{orderInfo.trans_price}}</text>
  75 + <text class="p2">免运费</text>
76 76 </text>
77 77 <text class="order-info-discount">
78 78 <text class="p1">优惠</text>
... ... @@ -127,22 +127,24 @@ import store from &#39;@/store&#39;
127 127 import UniCountdown from '../../components/UniCountdown/UniCountdown.vue'
128 128 export default {
129 129 components: {
130   - UniCountdown
  130 + UniCountdown,
131 131 },
132 132 data () {
133 133 return {
134 134 payId: '',
135 135 payTime: '',
136   - status: '',
  136 + status: '', // status 0 待付款 1 已发货
137 137 uid: '',
138 138 openid: '',
139   - lefttime: 0
  139 + lefttime: 0,
  140 + isPay: 0,
140 141 }
141 142 },
142 143 onLoad: function (option) {
143 144 console.log(option)
144 145 this.payId = option.payId
145 146 this.status = option.status
  147 + this.isPay = option.isPay
146 148 const openid = uni.getStorageSync('openid')
147 149 const uid = this.$store.state.user.uid
148 150 this.uid = uid
... ... @@ -150,11 +152,19 @@ export default {
150 152 store.dispatch('orderRead/getOrderInfo', {
151 153 pay_id: this.payId,
152 154 uid: '1',
153   - openid: openid
  155 + openid: openid,
154 156 })
155   -
156 157 // this.orderInfo = this.$store.state.orderRead.orderInfo
157 158 },
  159 + // 若从支付页面跳转过来,返回直接返回到首页
  160 + onBackPress(option) {
  161 + if (option.from === 'backbutton' && this.isPay) {
  162 + uni.switchTab({
  163 + url: '/pages/index/index',
  164 + })
  165 + return true // 阻止默认返回行为
  166 + }
  167 + },
158 168 computed: {
159 169 // 获取订单详细信息
160 170 orderInfo () {
... ... @@ -184,7 +194,7 @@ export default {
184 194 }
185 195 // console.log(totalDiscount)
186 196 return totalDiscount
187   - }
  197 + },
188 198 },
189 199 methods: {
190 200 // 取消订单
... ... @@ -202,12 +212,12 @@ export default {
202 212 store.dispatch('cancelOrder/cancel', {
203 213 keyname: '1',
204 214 uid: uid,
205   - openid: openid
  215 + openid: openid,
206 216 })
207 217 } else if (res.cancel) {
208 218 console.log('用户点击取消')
209 219 }
210   - }
  220 + },
211 221 })
212 222 },
213 223 paylog () {
... ... @@ -221,21 +231,21 @@ export default {
221 231 way: '2',
222 232 pay_id: this.payId,
223 233 judgeContent: '',
224   - orderInfo: this.orderInfo.order_info
  234 + orderInfo: this.orderInfo.order_info,
225 235 }).then(
226 236 setTimeout(() => {
227 237 uni.navigateBack()
228   - }, 1500)
  238 + }, 1500),
229 239 )
230   - }
  240 + },
231 241 },
232 242 filters: {
233 243 timerChange: function(value) {
234 244 var newDate = new Date()
235 245 newDate.setTime(value * 1000)
236 246 return newDate.toLocaleString()
237   - }
238   - }
  247 + },
  248 + },
239 249 }
240 250 </script>
241 251  
... ...
... ... @@ -0,0 +1,261 @@
  1 +/*
  2 + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  3 + * Digest Algorithm, as defined in RFC 1321.
  4 + * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  5 + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  6 + * Distributed under the BSD License
  7 + */
  8 +
  9 +/*
  10 + * Configurable variables. You may need to tweak these to be compatible with
  11 + * the server-side, but the defaults work in most cases.
  12 + */
  13 +var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  14 +var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  15 +var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  16 +
  17 +/*
  18 + * These are the functions you'll usually want to call
  19 + * They take string arguments and return either hex or base-64 encoded strings
  20 + */
  21 +function hex_md5(s) {
  22 + return binl2hex(core_md5(str2binl(s), s.length * chrsz));
  23 +}
  24 +
  25 +function b64_md5(s) {
  26 + return binl2b64(core_md5(str2binl(s), s.length * chrsz));
  27 +}
  28 +
  29 +function str_md5(s) {
  30 + return binl2str(core_md5(str2binl(s), s.length * chrsz));
  31 +}
  32 +
  33 +function hex_hmac_md5(key, data) {
  34 + return binl2hex(core_hmac_md5(key, data));
  35 +}
  36 +
  37 +function b64_hmac_md5(key, data) {
  38 + return binl2b64(core_hmac_md5(key, data));
  39 +}
  40 +
  41 +function str_hmac_md5(key, data) {
  42 + return binl2str(core_hmac_md5(key, data));
  43 +}
  44 +
  45 +/*
  46 + * Perform a simple self-test to see if the VM is working
  47 + */
  48 +function md5_vm_test() {
  49 + return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  50 +}
  51 +
  52 +/*
  53 + * Calculate the MD5 of an array of little-endian words, and a bit length
  54 + */
  55 +function core_md5(x, len) {
  56 + /* append padding */
  57 + x[len >> 5] |= 0x80 << ((len) % 32);
  58 + x[(((len + 64) >>> 9) << 4) + 14] = len;
  59 +
  60 + var a = 1732584193;
  61 + var b = -271733879;
  62 + var c = -1732584194;
  63 + var d = 271733878;
  64 +
  65 + for (var i = 0; i < x.length; i += 16) {
  66 + var olda = a;
  67 + var oldb = b;
  68 + var oldc = c;
  69 + var oldd = d;
  70 +
  71 + a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
  72 + d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
  73 + c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
  74 + b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
  75 + a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
  76 + d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
  77 + c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
  78 + b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
  79 + a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
  80 + d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
  81 + c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
  82 + b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
  83 + a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
  84 + d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
  85 + c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
  86 + b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
  87 +
  88 + a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
  89 + d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
  90 + c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
  91 + b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
  92 + a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
  93 + d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
  94 + c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
  95 + b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
  96 + a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
  97 + d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
  98 + c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
  99 + b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
  100 + a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
  101 + d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
  102 + c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
  103 + b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
  104 +
  105 + a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
  106 + d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
  107 + c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
  108 + b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
  109 + a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
  110 + d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
  111 + c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
  112 + b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
  113 + a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
  114 + d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
  115 + c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
  116 + b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
  117 + a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
  118 + d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
  119 + c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
  120 + b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
  121 +
  122 + a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
  123 + d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
  124 + c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
  125 + b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
  126 + a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
  127 + d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
  128 + c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
  129 + b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
  130 + a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
  131 + d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
  132 + c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
  133 + b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
  134 + a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
  135 + d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
  136 + c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
  137 + b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
  138 +
  139 + a = safe_add(a, olda);
  140 + b = safe_add(b, oldb);
  141 + c = safe_add(c, oldc);
  142 + d = safe_add(d, oldd);
  143 + }
  144 + return Array(a, b, c, d);
  145 +
  146 +}
  147 +
  148 +/*
  149 + * These functions implement the four basic operations the algorithm uses.
  150 + */
  151 +function md5_cmn(q, a, b, x, s, t) {
  152 + return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
  153 +}
  154 +
  155 +function md5_ff(a, b, c, d, x, s, t) {
  156 + return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  157 +}
  158 +
  159 +function md5_gg(a, b, c, d, x, s, t) {
  160 + return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  161 +}
  162 +
  163 +function md5_hh(a, b, c, d, x, s, t) {
  164 + return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  165 +}
  166 +
  167 +function md5_ii(a, b, c, d, x, s, t) {
  168 + return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  169 +}
  170 +
  171 +/*
  172 + * Calculate the HMAC-MD5, of a key and some data
  173 + */
  174 +function core_hmac_md5(key, data) {
  175 + var bkey = str2binl(key);
  176 + if (bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
  177 +
  178 + var ipad = Array(16),
  179 + opad = Array(16);
  180 + for (var i = 0; i < 16; i++) {
  181 + ipad[i] = bkey[i] ^ 0x36363636;
  182 + opad[i] = bkey[i] ^ 0x5C5C5C5C;
  183 + }
  184 +
  185 + var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  186 + return core_md5(opad.concat(hash), 512 + 128);
  187 +}
  188 +
  189 +/*
  190 + * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  191 + * to work around bugs in some JS interpreters.
  192 + */
  193 +function safe_add(x, y) {
  194 + var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  195 + var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  196 + return (msw << 16) | (lsw & 0xFFFF);
  197 +}
  198 +
  199 +/*
  200 + * Bitwise rotate a 32-bit number to the left.
  201 + */
  202 +function bit_rol(num, cnt) {
  203 + return (num << cnt) | (num >>> (32 - cnt));
  204 +}
  205 +
  206 +/*
  207 + * Convert a string to an array of little-endian words
  208 + * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  209 + */
  210 +function str2binl(str) {
  211 + var bin = Array();
  212 + var mask = (1 << chrsz) - 1;
  213 + for (var i = 0; i < str.length * chrsz; i += chrsz)
  214 + bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
  215 + return bin;
  216 +}
  217 +
  218 +/*
  219 + * Convert an array of little-endian words to a string
  220 + */
  221 +function binl2str(bin) {
  222 + var str = "";
  223 + var mask = (1 << chrsz) - 1;
  224 + for (var i = 0; i < bin.length * 32; i += chrsz)
  225 + str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & mask);
  226 + return str;
  227 +}
  228 +
  229 +/*
  230 + * Convert an array of little-endian words to a hex string.
  231 + */
  232 +function binl2hex(binarray) {
  233 + var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  234 + var str = "";
  235 + for (var i = 0; i < binarray.length * 4; i++) {
  236 + str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) +
  237 + hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
  238 + }
  239 + return str;
  240 +}
  241 +
  242 +/*
  243 + * Convert an array of little-endian words to a base-64 string
  244 + */
  245 +function binl2b64(binarray) {
  246 + var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  247 + var str = "";
  248 + for (var i = 0; i < binarray.length * 4; i += 3) {
  249 + var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16) |
  250 + (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8) |
  251 + ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
  252 + for (var j = 0; j < 4; j++) {
  253 + if (i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  254 + else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
  255 + }
  256 + }
  257 + return str;
  258 +}
  259 +module.exports = {
  260 + MD5: hex_md5
  261 +}
0 262 \ No newline at end of file
... ...