振吉方
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: JS 5組 - 2022 秋季 JS直播班, 最終關卡挑戰 Day4 - 後台(訂單列表 - 功能整合) title: 最終關卡挑戰 Day4 - 後台(訂單列表 - 功能整合) --- ###### tags: `JS 5組 - 2022 秋季 JS直播班` 、` 最終關卡挑戰 Day4 - 後台(訂單列表 - 功能整合)` ###### *date: 2022 / 11/ 23* # Day4 - 後台(訂單列表 - 功能整合) 昨天我們已經完成前台頁面的 **API資料串接** 與 **功能整合**,今天將進入到後台開發的訂單列表 API設計。 ### 今日挑戰目標: 後台(訂單列表 - 功能整合) ![](https://i.imgur.com/UuM6X4E.jpg) ### 使用 API ![](https://i.imgur.com/pxuyK1m.jpg) ### 確認 API 路徑 ![](https://i.imgur.com/wQwmEWk.png) ![](https://i.imgur.com/hxJzx32.png) ### 訂單列表 - 功能整合任務 - 取得訂單列表 - 刪除單筆訂單 - 刪除全部訂單 - 修改訂單狀態 - 處理日期格式 (timestamp) ### 後台開發資源整理 - [後台版型](https://codepen.io/hexschool/pen/WNJXgrR?editors=1010) --- ### shinyhung#3825 ```javascript ``` ### WeiJ#7376 後台的功能上和前台基本一模一樣,特別的部份在訂單 API 回傳的時間為時間戳(timestamp),關於時間戳轉換為日期字串 我拉出來而外寫一個 date.js,好處是以後有在遇到時間相關的都可以在寫到這個 js 來 更可以拿到別的專案當做一個套件使用 ```javascript /* @param {int} timestamp @return {string} 2020-01-01 */ export const timestampToTime = timestamp => { const date = new Date(timestamp * 1000) const Y = date.getFullYear() + '-'; const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; const D = date.getDate() + ' '; return Y + M + D; } ``` ### charlottelee849#0366 待辦事項 - 前台優化 - [x] 加入 Loding 效果 - 後台 - [x] c3圖表 - [x] 日期格式 (時間戳) - [x] 刪除訂單 - [x] 狀態修改 - [x] 加入 Loding 效果 **前台知識點** 加入 lading... 效果,在axios之前加入讓 loading 顯示 ```JavaScript= document.getElementById("preloder").style.display = "block"; axios.... ``` .catch 之後加入 finally => 讓 loading 消失 ( catch 沒用到可以省略 ) ```JavaScript= .finally(() => { document.getElementById("preloder").style.display = "none"; }); ``` ### jimmyFang#9575 **任務清單** - 後台開發 - [x] 取得訂單列表 - [x] 刪除單筆訂單 - [x] 刪除全部訂單 - [x] 修改訂單狀態 - [x] 處理日期格式 (timestamp) - 整理專案結構 - [x] 複習 [JS ESM 開發核心課程](https://rpg.hexschool.com/training/32/show?embedhm=wHOMdhGtQRu7IxOM8FwQIA) - [x] 使用 JS ESM 整合 通用 JS 與 [API 統一管理](https://github.com/WeiJ0/Hexscholl-JSLive-Final/blob/main/helper/api.js)(參考 WeiJ 程式) 目前進度: [demo](https://jimmyfang-ai.github.io/js-finalWork-wowoRoom/#orderInfo) **知識點分享:** 訂單資料在跑迴圈時並在付款按鈕,直接使用 **條件 (三元) 運算子** , **order.isPaid ? '已付款' : '未付款'**,就可依照資料的內的付款狀態去顯示相對應的字串。 <iframe height="300" style="width: 100%;" scrolling="no" title="條件 (三元) 運算子" src="https://codepen.io/pohxiqqo/embed/LYrmEdw?default-tab=html%2Cresult" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"> See the Pen <a href="https://codepen.io/pohxiqqo/pen/LYrmEdw"> 條件 (三元) 運算子</a> by 方振吉 (<a href="https://codepen.io/pohxiqqo">@pohxiqqo</a>) on <a href="https://codepen.io">CodePen</a>. </iframe> ### Judy Wei#6103 ```JavaScript ``` ### Mia小福#4473 ```JavaScript ``` ### Ringo#7583 ```JavaScript ``` ### yawun#0042 - 後台開發 - [x] 取得訂單列表 - [x] 刪除單筆訂單 - [x] 刪除全部訂單 - [x] 修改訂單狀態 - [x] 處理日期格式 (timestamp) - 整理專案結構 - [x] 使用 JS ESM 整合 JS 檔案架構(整合API和通用JS、未整合外部函式) - [x] API統一管理(參考WeiJ程式) - 知識點分享 ### 法希娜#3206 ->>完成: 一般商品顯示 購物車顯示+正確總額 購物車單筆刪除 全部刪除 加入購物車 送出訂單 ->>待完成:輸入驗證/ 送出訂單後清空購物車 **本次新增知識點: (一)抓取擁有同樣class但各自不同id的元素,求個別click事件的該id ```JavaScript const addCardBtn = document.querySelectorAll('.addCardBtn'); addCardBtn.forEach((btn) =>{ btn.addEventListener('click', (e) => { const idVal = e.target.getAttribute('id'); }) }) ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully