小程序模板網(wǎng)

微信小程序刪除處理

發(fā)布時間:2017-12-25 11:38 所屬欄目:小程序開發(fā)教程

沒有 confrim 那怎么實現(xiàn)這個效果呢 ?

 
 
 

沒有 confrim 那怎么實現(xiàn)這個效果呢 
可以使用小程序里的模態(tài)框 
代碼:

wxml:

 

		
  1. <a class="reply" wx:if="{{comment.uid==comment.login_uid}}" bindtap="del" data-cid="{{comment.c_id}}">刪除</a>

js:

 

		
  1. del:function(e){
  2. var that = this;
  3. wx.showModal({
  4. title: '提示',
  5. content: '確定要刪除嗎?',
  6. success: function (sm) {
  7. if (sm.confirm) {
  8. // 用戶點擊了確定 可以調(diào)用刪除方法了
  9. wx.request({
  10. url: 'https://m.*****.com/index.php/Home/Xiaoxxf/home_comment_del?c_id=' + e.currentTarget.dataset.cid, //刪除房間評論
  11. data: '',
  12. header: {
  13. 'Content-Type': 'application/json'
  14. },
  15. method: 'GET',
  16. success: function (res) {
  17. console.log(res);
  18. wx.showToast({
  19. title: res.data, //數(shù)據(jù)返回提示,查看后臺PHP
  20. icon: 'success',
  21. duration: 2000
  22. })
  23. /* 獲取房間評論信息 -xzz 0714*/
  24. getList(that);
  25. },
  26. fail: function (res) { },
  27. complete: function (res) { },
  28. })
  29. } else if (sm.cancel) {
  30. }
  31. }
  32. })
  33. }

效果:

這樣就實現(xiàn)js的confirm效果了。



易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.u-renovate.com/wxmini/doc/course/18241.html 復制鏈接 如需定制請聯(lián)系易優(yōu)客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×